@sanity/ui 4.3.1 → 4.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tooltip.js CHANGED
@@ -181,7 +181,7 @@ 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(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;
185
185
  $[0] === fallbackPlacementsProp ? t6 = $[1] : (t6 = _getArrayProp(fallbackPlacementsProp), $[0] = fallbackPlacementsProp, $[1] = t6);
186
186
  let fallbackPlacements = t6, ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), [tooltipMaxWidth, setTooltipMaxWidth] = useState(0), t7;
187
187
  $[2] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => ref.current, $[2] = t7) : t7 = $[2], useImperativeHandle(forwardedRef, t7);
@@ -276,28 +276,31 @@ function Tooltip(props) {
276
276
  let t26;
277
277
  $[62] === showTooltip ? t26 = $[63] : (t26 = [showTooltip], $[62] = showTooltip, $[63] = t26), useEffect(t25, t26);
278
278
  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);
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];
285
286
  let t29;
286
- $[70] === update ? t29 = $[71] : (t29 = (arrowEl) => {
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) => {
287
290
  arrowRef.current = arrowEl, update();
288
- }, $[70] = update, $[71] = t29);
289
- let setArrow = t29, t30;
290
- $[72] === refs ? t30 = $[73] : (t30 = (node) => {
291
+ }, $[74] = update, $[75] = t30);
292
+ let setArrow = t30, t31;
293
+ $[76] === refs ? t31 = $[77] : (t31 = (node) => {
291
294
  ref.current = node, refs.setFloating(node);
292
- }, $[72] = refs, $[73] = t30);
293
- let setFloating = t30, t31;
295
+ }, $[76] = refs, $[77] = t31);
296
+ let setFloating = t31, t32;
294
297
  bb0: {
295
298
  if (!childProp) {
296
- t31 = null;
299
+ t32 = null;
297
300
  break bb0;
298
301
  }
299
- let t32;
300
- $[74] !== childProp || $[75] !== handleBlur || $[76] !== handleClick || $[77] !== handleContextMenu || $[78] !== handleFocus || $[79] !== handleMouseEnter || $[80] !== handleMouseLeave ? (t32 = cloneElement(childProp, {
302
+ let t33;
303
+ $[78] !== childProp || $[79] !== handleBlur || $[80] !== handleClick || $[81] !== handleContextMenu || $[82] !== handleFocus || $[83] !== handleMouseEnter || $[84] !== handleMouseLeave ? (t33 = cloneElement(childProp, {
301
304
  onBlur: handleBlur,
302
305
  onFocus: handleFocus,
303
306
  onMouseEnter: handleMouseEnter,
@@ -305,23 +308,23 @@ function Tooltip(props) {
305
308
  onClick: handleClick,
306
309
  onContextMenu: handleContextMenu,
307
310
  ref: setReferenceElement
308
- }), $[74] = childProp, $[75] = handleBlur, $[76] = handleClick, $[77] = handleContextMenu, $[78] = handleFocus, $[79] = handleMouseEnter, $[80] = handleMouseLeave, $[81] = t32) : t32 = $[81], t31 = t32;
311
+ }), $[78] = childProp, $[79] = handleBlur, $[80] = handleClick, $[81] = handleContextMenu, $[82] = handleFocus, $[83] = handleMouseEnter, $[84] = handleMouseLeave, $[85] = t33) : t33 = $[85], t32 = t33;
309
312
  }
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;
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;
316
319
  }
317
320
  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 = {
321
+ let T0 = Layer, t37 = clsx(tooltipLayer, restProps.className), t38 = tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0, t39;
322
+ $[92] !== floatingStyles || $[93] !== t38 ? (t39 = {
320
323
  ...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, {
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, {
325
328
  ...restProps,
326
329
  animate,
327
330
  arrow: arrowProp,
@@ -337,33 +340,46 @@ function Tooltip(props) {
337
340
  scheme,
338
341
  shadow,
339
342
  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, {
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, {
343
346
  "data-ui": "Tooltip",
344
347
  ...restProps,
345
- className: t36,
348
+ className: t37,
346
349
  ref: setFloating,
347
- style: t38,
350
+ style: t39,
348
351
  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, {
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, {
353
356
  __unstable_name: typeof portalProp == "string" ? portalProp : void 0,
354
357
  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, {
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, {
358
361
  layoutMode: "default",
359
362
  mode: showTooltip ? "visible" : "hidden",
360
363
  children: tooltipNode
361
364
  }) : /* @__PURE__ */ jsx(Activity, {
362
365
  mode: showTooltip ? "visible" : "hidden",
363
366
  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;
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;
370
+ }
371
+ /**
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.
374
+ *
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.
379
+ */
380
+ function measureAvailableWidth(boundaryElement, portalElement) {
381
+ let availableWidths = [...boundaryElement ? [boundaryElement.offsetWidth] : [], portalElement?.offsetWidth || document.body.offsetWidth];
382
+ return Math.min(...availableWidths);
367
383
  }
368
384
  function useMiddleware(t0) {
369
385
  let $ = c(17), { animate, arrowProp, arrowRef, boundaryElement, fallbackPlacements, rootBoundary } = t0, ret;
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.js","names":["(nextState: SetStateAction<S>, delay?: number) => {\n const action = () => {\n setState(nextState)\n }\n\n // A new state change has been initiated, cancel the previous one.\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n delayedAction.current = undefined\n }\n\n if (!delay) return action()\n delayedAction.current = setTimeout(action, delay)\n }","useCallback((nextState: SetStateAction<S>, delay?: number) => {\n const action = () => {\n setState(nextState)\n }\n\n // A new state change has been initiated, cancel the previous one.\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n delayedAction.current = undefined\n }\n\n if (!delay) return action()\n delayedAction.current = setTimeout(action, delay)\n }, [])","() => {\n return () => {\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n }\n }\n }","[]","[state, onStateChange]","_c","getTransformOrigin(originX, originY)","{\n transformOrigin: getTransformOrigin(originX, originY),\n willChange: animate ? 'transform' : undefined,\n ...style,\n }","animate ? 'transform' : undefined","useMemo(\n () => ({\n transformOrigin: getTransformOrigin(originX, originY),\n willChange: animate ? 'transform' : undefined,\n ...style,\n }),\n [animate, originX, originY, style],\n )","{\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }","arrowX !== null ? arrowX : undefined","arrowY !== null ? arrowY : undefined","useMemo(\n () => ({\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }),\n [arrowX, arrowY],\n )","clsx(tooltipCard, className)","arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_TOOLTIP_ARROW_WIDTH}\n height={DEFAULT_TOOLTIP_ARROW_HEIGHT}\n radius={DEFAULT_TOOLTIP_ARROW_RADIUS}\n />\n )","<MotionCard\n className={clsx(tooltipCard, className)}\n data-ui=\"Tooltip__card\"\n {...restProps}\n data-placement={placement}\n padding={padding}\n radius={radius}\n ref={ref}\n scheme={scheme}\n shadow={shadow}\n style={rootStyle}\n {...(animate ? POPOVER_MOTION_PROPS : undefined)}\n >\n {children}\n\n {arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_TOOLTIP_ARROW_WIDTH}\n height={DEFAULT_TOOLTIP_ARROW_HEIGHT}\n radius={DEFAULT_TOOLTIP_ARROW_RADIUS}\n />\n )}\n </MotionCard>","animate ? POPOVER_MOTION_PROPS : undefined","_c","_animate = false","arrowProp = false","placementProp = 'bottom'","padding = 2","radius = 2","shadow = 2","_getArrayProp(fallbackPlacementsProp)","() => ref.current","{\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n rootBoundary,\n }","{reference: referenceElement}","{\n middleware,\n placement: placementProp,\n whileElementsMounted: autoUpdate,\n elements: {reference: referenceElement},\n }","delayGroupContext || {}","(open: boolean, immediate?: boolean) => {\n if (isInsideGroup) {\n // When it's inside a group, the open or close status will be handled by the group.\n if (open) {\n const groupedOpenDelay = immediate ? 0 : openDelay\n\n setIsGroupActive?.(open, groupedOpenDelay)\n setOpenTooltipId?.(tooltipId, groupedOpenDelay)\n } else {\n const minimumGroupDeactivateDelay = 200 // We should provide some delay to allow the user to reach the next tooltip.\n const groupDeactivateDelay =\n closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay\n\n setIsGroupActive?.(open, groupDeactivateDelay)\n setOpenTooltipId?.(null, immediate ? 0 : closeDelay)\n }\n } else {\n const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay\n\n // When it's not inside a group, the open or close status will be handled by the tooltip itself.\n setIsOpen(open, standaloneDelay)\n }\n }","useCallback(\n (open: boolean, immediate?: boolean) => {\n if (isInsideGroup) {\n // When it's inside a group, the open or close status will be handled by the group.\n if (open) {\n const groupedOpenDelay = immediate ? 0 : openDelay\n\n setIsGroupActive?.(open, groupedOpenDelay)\n setOpenTooltipId?.(tooltipId, groupedOpenDelay)\n } else {\n const minimumGroupDeactivateDelay = 200 // We should provide some delay to allow the user to reach the next tooltip.\n const groupDeactivateDelay =\n closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay\n\n setIsGroupActive?.(open, groupDeactivateDelay)\n setOpenTooltipId?.(null, immediate ? 0 : closeDelay)\n }\n } else {\n const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay\n\n // When it's not inside a group, the open or close status will be handled by the tooltip itself.\n setIsOpen(open, standaloneDelay)\n }\n },\n [\n isInsideGroup,\n openDelay,\n setIsGroupActive,\n setOpenTooltipId,\n tooltipId,\n closeDelay,\n setIsOpen,\n ],\n )","(e: FocusEvent) => {\n handleIsOpenChange(false)\n childProp?.props?.onBlur?.(e)\n }","props","useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(false)\n childProp?.props?.onBlur?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onClick?.(e)\n }","e","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onClick?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onContextMenu?.(e)\n }","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onContextMenu?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: FocusEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onFocus?.(e)\n }","useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onFocus?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onMouseEnter?.(e)\n }","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onMouseEnter?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(false)\n childProp?.props?.onMouseLeave?.(e)\n }","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false)\n childProp?.props?.onMouseLeave?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","{handleIsOpenChange, referenceElement, showTooltip, isInsideGroup}","() => {\n if (disabled && showTooltip) handleIsOpenChange(false)\n }","[disabled, handleIsOpenChange, showTooltip]","() => {\n if (!content && showTooltip) handleIsOpenChange(false)\n }","[content, handleIsOpenChange, showTooltip]","() => handleIsOpenChange(false, true)","() => {\n // If the user clicks on escape key, close the tooltip.\n if (!showTooltip) return\n\n function handleWindowKeyDown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n onWindowEscape()\n }\n }\n\n window.addEventListener('keydown', handleWindowKeyDown)\n\n // oxlint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('keydown', handleWindowKeyDown)\n }\n }","[showTooltip]","() => {\n // Get the maximum tooltip width (sans tooltip padding)\n // Tooltip width should never exceed the width of either any supplied boundary or portal element.\n // If both portal and boundary elements are provided, use the smaller width of the two.\n const availableWidths = [\n ...(boundaryElement ? [boundaryElement.offsetWidth] : []),\n portalElement?.offsetWidth || document.body.offsetWidth,\n ]\n\n // oxlint-disable-next-line react/set-state-in-effect\n setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2)\n }","offsetWidth","[boundaryElement, portalElement]","(arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n update()\n }","useCallback(\n (arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n update()\n },\n [update],\n )","(node: HTMLDivElement | null) => {\n ref.current = node\n refs.setFloating(node)\n }","useCallback(\n (node: HTMLDivElement | null) => {\n ref.current = node\n refs.setFloating(node)\n },\n [refs],\n )","useMemo(() => {\n if (!childProp) return null\n\n return cloneElement(childProp, {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onClick: handleClick,\n onContextMenu: handleContextMenu,\n ref: setReferenceElement,\n })\n }, [\n childProp,\n handleBlur,\n handleClick,\n handleContextMenu,\n handleFocus,\n handleMouseEnter,\n handleMouseLeave,\n ])","cloneElement(childProp, {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onClick: handleClick,\n onContextMenu: handleContextMenu,\n ref: setReferenceElement,\n })","childProp ? getElementRef(childProp) : null","() => referenceElement","[\n referenceElement,\n ]","<></>","{\n ...floatingStyles,\n maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : undefined,\n }","tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : undefined","<TooltipCard\n {...restProps}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n originX={originX}\n originY={originY}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n >\n {content}\n </TooltipCard>","<Layer\n data-ui=\"Tooltip\"\n {...restProps}\n className={clsx(tooltipLayer, restProps.className)}\n ref={setFloating}\n style={{\n ...floatingStyles,\n maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : undefined,\n }}\n zOffset={zOffset}\n >\n <TooltipCard\n {...restProps}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n originX={originX}\n originY={originY}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n >\n {content}\n </TooltipCard>\n </Layer>","Layer","clsx(tooltipLayer, restProps.className)","\"Tooltip\"","portalProp ? (\n <Portal __unstable_name={typeof portalProp === 'string' ? portalProp : undefined}>\n {tooltip}\n </Portal>\n ) : (\n tooltip\n )","animate ? (\n <AnimateActivity layoutMode=\"default\" mode={showTooltip ? 'visible' : 'hidden'}>\n {tooltipNode}\n </AnimateActivity>\n ) : (\n <Activity mode={showTooltip ? 'visible' : 'hidden'}>{tooltipNode}</Activity>\n )","<>\n {/* the tooltip */}\n {animate ? (\n <AnimateActivity layoutMode=\"default\" mode={showTooltip ? 'visible' : 'hidden'}>\n {tooltipNode}\n </AnimateActivity>\n ) : (\n <Activity mode={showTooltip ? 'visible' : 'hidden'}>{tooltipNode}</Activity>\n )}\n\n {/* the referred element */}\n {child}\n </>","{\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n rootBoundary,\n}: {\n animate: boolean\n arrowProp: boolean\n arrowRef: React.RefObject<HTMLDivElement | null>\n boundaryElement: HTMLElement | null\n fallbackPlacements: Placement[]\n rootBoundary: RootBoundary\n}","flip({\n boundary: boundaryElement || undefined,\n fallbackPlacements,\n padding: DEFAULT_TOOLTIP_PADDING,\n rootBoundary,\n })","boundaryElement || undefined","offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE})","shift({\n boundary: boundaryElement || undefined,\n rootBoundary,\n padding: DEFAULT_TOOLTIP_PADDING,\n })","arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING})","useMemo(() => {\n const ret: Middleware[] = []\n\n // Flip the floating element when leaving the boundary box\n ret.push(\n flip({\n boundary: boundaryElement || undefined,\n fallbackPlacements,\n padding: DEFAULT_TOOLTIP_PADDING,\n rootBoundary,\n }),\n )\n\n // Define distance between reference and floating element\n ret.push(offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE}))\n\n // Shift the tooltip so its sits with the boundary element\n ret.push(\n shift({\n boundary: boundaryElement || undefined,\n rootBoundary,\n padding: DEFAULT_TOOLTIP_PADDING,\n }),\n )\n\n // Place arrow\n if (arrowProp) {\n ret.push(arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING}))\n }\n\n // Determine the origin to scale from.\n // Must be placed after `@sanity/ui/size` and `shift` middleware.\n if (animate) {\n ret.push(origin)\n }\n\n return ret\n }, [animate, arrowProp, arrowRef, boundaryElement, fallbackPlacements, rootBoundary])","{\n handleIsOpenChange,\n referenceElement,\n showTooltip,\n isInsideGroup,\n}: {\n handleIsOpenChange: (open: boolean, immediate?: boolean) => void\n referenceElement: HTMLElement | null\n showTooltip: boolean\n isInsideGroup: boolean\n}","(target: EventTarget | null, teardown: () => void) => {\n if (!referenceElement) return\n\n const isHoveringReference =\n referenceElement === target || (target instanceof Node && referenceElement.contains(target))\n\n if (!isHoveringReference) {\n handleIsOpenChange(false)\n // Allow removing the event listener eagerly, to avoid race conditions\n teardown()\n }\n }","() => {\n if (!showTooltip || isInsideGroup) return\n\n const handleMouseMove = (event: MouseEvent) => {\n onMouseMove(event.target, () => window.removeEventListener('mousemove', handleMouseMove))\n }\n\n window.addEventListener('mousemove', handleMouseMove)\n\n // oxlint-disable-next-line consistent-return\n return () => window.removeEventListener('mousemove', handleMouseMove)\n }","[isInsideGroup, showTooltip]","_c","_Fragment","{\n setIsGroupActive: setIsGroupActive,\n openTooltipId: openTooltipId,\n setOpenTooltipId: setOpenTooltipId,\n // When the group is active, we want the next tooltip to open immediately.\n openDelay: isGroupActive ? 1 : openDelay,\n closeDelay: closeDelay,\n }","isGroupActive ? 1 : openDelay","useMemo(\n () => ({\n setIsGroupActive: setIsGroupActive,\n openTooltipId: openTooltipId,\n setOpenTooltipId: setOpenTooltipId,\n // When the group is active, we want the next tooltip to open immediately.\n openDelay: isGroupActive ? 1 : openDelay,\n closeDelay: closeDelay,\n }),\n [closeDelay, isGroupActive, openDelay, openTooltipId, setIsGroupActive, setOpenTooltipId],\n )","<TooltipDelayGroupContext.Provider value={value}>{children}</TooltipDelayGroupContext.Provider>","TooltipDelayGroupContext.Provider","_c","\"top\"","\"bottom\"","\"left\"","\"right\""],"sources":["../src/core/hooks/useDelayedState.ts","../src/core/primitives/tooltip/constants.ts","../src/core/primitives/tooltip/tooltip.css.ts","../src/core/primitives/tooltip/tooltipCard.tsx","../src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupContext.tsx","../src/core/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts","../src/core/primitives/tooltip/tooltip.tsx","../src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx"],"sourcesContent":["import {SetStateAction, useCallback, useEffect, useRef, useState} from 'react'\n\n/**\n * @beta\n */\nexport function useDelayedState<S>(\n initialState: S | (() => S),\n): [S, (nextState: SetStateAction<S>, delay?: number) => void] {\n const [state, setState] = useState(initialState)\n const delayedAction = useRef<NodeJS.Timeout | undefined>(undefined)\n\n const onStateChange = useCallback((nextState: SetStateAction<S>, delay?: number) => {\n const action = () => {\n setState(nextState)\n }\n\n // A new state change has been initiated, cancel the previous one.\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n delayedAction.current = undefined\n }\n\n if (!delay) return action()\n delayedAction.current = setTimeout(action, delay)\n }, [])\n\n useEffect(() => {\n return () => {\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n }\n }\n }, [])\n\n return [state, onStateChange]\n}\n","import {Placement} from '@floating-ui/react-dom'\n\nexport const DEFAULT_TOOLTIP_ARROW_WIDTH = 15\nexport const DEFAULT_TOOLTIP_ARROW_HEIGHT = 6\nexport const DEFAULT_TOOLTIP_ARROW_RADIUS = 2\n\nexport const DEFAULT_TOOLTIP_DISTANCE = 4\nexport const DEFAULT_TOOLTIP_PADDING = 4\n\nexport const DEFAULT_FALLBACK_PLACEMENTS: Record<Placement, Placement[]> = {\n 'top': ['top-end', 'top-start', 'bottom', 'left', 'right'],\n 'top-start': ['top', 'top-end', 'bottom-start', 'left-start', 'right-start'],\n 'top-end': ['top', 'top-start', 'bottom-end', 'left-end', 'right-end'],\n 'bottom': ['bottom-end', 'bottom-start', 'top', 'left', 'right'],\n 'bottom-start': ['bottom', 'bottom-end', 'top-start', 'left-start', 'right-start'],\n 'bottom-end': ['bottom', 'bottom-start', 'top-end', 'left-end', 'right-end'],\n 'left': ['left-end', 'left-start', 'right', 'top', 'bottom'],\n 'left-start': ['left', 'left-end', 'right-start', 'top-start', 'bottom-start'],\n 'left-end': ['left', 'left-start', 'right-end', 'top-end', 'bottom-end'],\n 'right': ['right-end', 'right-start', 'left', 'top', 'bottom'],\n 'right-start': ['right', 'right-end', 'left-start', 'top-start', 'bottom-start'],\n 'right-end': ['right', 'right-start', 'left-end', 'top-end', 'bottom-end'],\n}\n","import {style} from '@vanilla-extract/css'\n\nexport const tooltipLayer = style({\n pointerEvents: 'none',\n})\n\nexport const tooltipCard = style({\n willChange: 'transform',\n})\n","import {clsx} from 'clsx/lite'\nimport {motion} from 'motion/react'\nimport React, {CSSProperties, useMemo} from 'react'\n\nimport {ThemeColorSchemeKey} from '../../../theme/system/color/_system'\nimport {POPOVER_MOTION_PROPS} from '../../constants'\nimport {getTransformOrigin} from '../../middleware/origin'\nimport {Placement} from '../../types/placement'\nimport {Radius} from '../../types/radius'\nimport {Arrow} from '../../utils/arrow/arrow'\nimport {Card} from '../card/card'\nimport {\n DEFAULT_TOOLTIP_ARROW_HEIGHT,\n DEFAULT_TOOLTIP_ARROW_RADIUS,\n DEFAULT_TOOLTIP_ARROW_WIDTH,\n} from './constants'\n\nimport {tooltipCard} from './tooltip.css'\n\nconst MotionCard = motion.create(Card)\n\n/**\n * @internal\n */\nexport function TooltipCard(\n props: {\n animate?: boolean\n arrow: boolean\n arrowRef: React.Ref<HTMLDivElement>\n arrowX?: number\n arrowY?: number\n originX?: number\n originY?: number\n padding?: number | number[]\n placement?: Placement\n radius?: Radius | Radius[]\n scheme?: ThemeColorSchemeKey\n shadow?: number | number[]\n } & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'width'>,\n) {\n const {\n animate,\n arrow,\n arrowRef,\n arrowX,\n arrowY,\n children,\n className,\n originX,\n originY,\n padding,\n placement,\n radius,\n ref,\n scheme,\n shadow,\n style,\n ...restProps\n } = props\n\n const rootStyle: CSSProperties = useMemo(\n () => ({\n transformOrigin: getTransformOrigin(originX, originY),\n willChange: animate ? 'transform' : undefined,\n ...style,\n }),\n [animate, originX, originY, style],\n )\n\n const arrowStyle: CSSProperties = useMemo(\n () => ({\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }),\n [arrowX, arrowY],\n )\n\n return (\n <MotionCard\n className={clsx(tooltipCard, className)}\n data-ui=\"Tooltip__card\"\n {...restProps}\n data-placement={placement}\n padding={padding}\n radius={radius}\n ref={ref}\n scheme={scheme}\n shadow={shadow}\n style={rootStyle}\n {...(animate ? POPOVER_MOTION_PROPS : undefined)}\n >\n {children}\n\n {arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_TOOLTIP_ARROW_WIDTH}\n height={DEFAULT_TOOLTIP_ARROW_HEIGHT}\n radius={DEFAULT_TOOLTIP_ARROW_RADIUS}\n />\n )}\n </MotionCard>\n )\n}\n","import {createGlobalScopedContext} from '../../../lib/createGlobalScopedContext'\nimport {TooltipDelayGroupContextValue} from './types'\n\n/**\n * @beta\n */\nexport const TooltipDelayGroupContext =\n createGlobalScopedContext<TooltipDelayGroupContextValue | null>(\n '@sanity/ui/context/tooltipDelayGroup',\n null,\n )\n","import {useContext} from 'react'\n\nimport {TooltipDelayGroupContext} from './tooltipDelayGroupContext'\nimport {TooltipDelayGroupContextValue} from './types'\n\n/**\n * @beta\n */\nexport function useTooltipDelayGroup(): TooltipDelayGroupContextValue | null {\n const value = useContext(TooltipDelayGroupContext)\n\n return value\n}\n","import {\n arrow,\n autoUpdate,\n flip,\n type Middleware,\n offset,\n type RootBoundary,\n shift,\n useFloating,\n} from '@floating-ui/react-dom'\nimport {clsx} from 'clsx/lite'\nimport {\n Activity,\n cloneElement,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n// TODO: switch to `useEffectEvent` from `react` once\n// https://github.com/facebook/react/issues/34818 is fixed in the lowest React\n// version we support: on React 19.2 the native hook never sees values past\n// the first render when the calling component is wrapped in `forwardRef` or\n// `memo`, and consumers may wrap `Tooltip` in `memo`.\nimport {useEffectEvent} from 'use-effect-event'\n\nimport type {ThemeColorSchemeKey} from '../../../theme/system/color/_system'\nimport {useDelayedState} from '../../hooks/useDelayedState'\nimport {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'\nimport {origin} from '../../middleware/origin'\nimport {_getArrayProp} from '../../styles/helpers'\nimport {useTheme_v2} from '../../theme/useTheme'\nimport type {Placement} from '../../types/placement'\nimport {AnimateActivity} from '../../utils/animateActivity'\nimport {useBoundaryElement} from '../../utils/boundaryElement/useBoundaryElement'\nimport {getElementRef} from '../../utils/getElementRef'\nimport {Layer, type LayerProps} from '../../utils/layer/layer'\nimport {Portal} from '../../utils/portal/portal'\nimport {usePortal} from '../../utils/portal/usePortal'\nimport type {Delay} from '../types'\nimport {\n DEFAULT_FALLBACK_PLACEMENTS,\n DEFAULT_TOOLTIP_DISTANCE,\n DEFAULT_TOOLTIP_PADDING,\n} from './constants'\nimport {TooltipCard} from './tooltipCard'\nimport {useTooltipDelayGroup} from './tooltipDelayGroup/useTooltipDelayGroup'\n\nimport {tooltipLayer} from './tooltip.css'\n\n/**\n * @public\n */\nexport interface TooltipProps extends Omit<LayerProps, 'as'> {\n /** @deprecated Use `fallbackPlacements` instead. */\n allowedAutoPlacements?: never\n arrow?: boolean\n boundaryElement?: HTMLElement | null\n children?: React.JSX.Element\n content?: React.ReactNode\n disabled?: boolean\n fallbackPlacements?: Placement[]\n padding?: number | number[]\n placement?: Placement\n /** Whether or not to render the tooltip in a portal element. */\n portal?: boolean | string\n radius?: number | number[]\n scheme?: ThemeColorSchemeKey\n shadow?: number | number[]\n /**\n * Adds a delay to open or close the tooltip.\n *\n * If only a `number` is passed, it will be used for both opening and closing.\n *\n * If an object `{open: number; close:number}` is passed, it can be used to set different delays for each action.\n *\n * @public\n * @defaultValue 0\n */\n delay?: Delay\n /**\n * Whether the tooltip should animate in and out.\n *\n * @beta\n * @defaultValue false\n */\n animate?: boolean\n}\n\n/**\n * Tooltips display information when hovering, focusing or tapping.\n *\n * @public\n */\nexport function Tooltip(\n props: TooltipProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content'>,\n) {\n const boundaryElementContext = useBoundaryElement()\n const {layer} = useTheme_v2()\n const {\n animate: _animate = false,\n arrow: arrowProp = false,\n boundaryElement: _boundaryElement,\n children: childProp,\n content,\n disabled,\n fallbackPlacements: _fallbackPlacementsProp,\n padding = 2,\n placement: placementProp = 'bottom',\n portal: portalProp,\n radius = 2,\n ref: forwardedRef,\n scheme,\n shadow = 2,\n zOffset: _zOffset,\n delay,\n ...restProps\n } = props\n const boundaryElement = _boundaryElement ?? boundaryElementContext?.element\n const fallbackPlacementsProp =\n _fallbackPlacementsProp ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? 'bottom']\n const zOffset = _zOffset ?? layer.tooltip.zOffset\n const prefersReducedMotion = usePrefersReducedMotion()\n const animate = prefersReducedMotion ? false : _animate\n const fallbackPlacements = _getArrayProp(fallbackPlacementsProp)\n const ref = useRef<HTMLDivElement | null>(null)\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null)\n const arrowRef = useRef<HTMLDivElement | null>(null)\n const rootBoundary: RootBoundary = 'viewport'\n const [tooltipMaxWidth, setTooltipMaxWidth] = useState(0)\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => ref.current)\n\n const portal = usePortal()\n const portalElement =\n typeof portalProp === 'string' ? portal.elements?.[portalProp] || null : portal.element\n\n const middleware = useMiddleware({\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n rootBoundary,\n })\n\n const {floatingStyles, placement, middlewareData, refs, update} = useFloating({\n middleware,\n placement: placementProp,\n whileElementsMounted: autoUpdate,\n elements: {reference: referenceElement},\n })\n\n const arrowX = middlewareData.arrow?.x\n const arrowY = middlewareData.arrow?.y\n\n const originX = middlewareData['@sanity/ui/origin']?.originX\n const originY = middlewareData['@sanity/ui/origin']?.originY\n\n const tooltipId = useId()\n const [isOpen, setIsOpen] = useDelayedState(false)\n const delayGroupContext = useTooltipDelayGroup()\n const {setIsGroupActive, setOpenTooltipId} = delayGroupContext || {}\n const showTooltip = isOpen || delayGroupContext?.openTooltipId === tooltipId\n\n const isInsideGroup = delayGroupContext !== null\n const openDelayProp = typeof delay === 'number' ? delay : delay?.open || 0\n const closeDelayProp = typeof delay === 'number' ? delay : delay?.close || 0\n\n const openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp\n const closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp\n\n const handleIsOpenChange = useCallback(\n (open: boolean, immediate?: boolean) => {\n if (isInsideGroup) {\n // When it's inside a group, the open or close status will be handled by the group.\n if (open) {\n const groupedOpenDelay = immediate ? 0 : openDelay\n\n setIsGroupActive?.(open, groupedOpenDelay)\n setOpenTooltipId?.(tooltipId, groupedOpenDelay)\n } else {\n const minimumGroupDeactivateDelay = 200 // We should provide some delay to allow the user to reach the next tooltip.\n const groupDeactivateDelay =\n closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay\n\n setIsGroupActive?.(open, groupDeactivateDelay)\n setOpenTooltipId?.(null, immediate ? 0 : closeDelay)\n }\n } else {\n const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay\n\n // When it's not inside a group, the open or close status will be handled by the tooltip itself.\n setIsOpen(open, standaloneDelay)\n }\n },\n [\n isInsideGroup,\n openDelay,\n setIsGroupActive,\n setOpenTooltipId,\n tooltipId,\n closeDelay,\n setIsOpen,\n ],\n )\n\n const handleBlur = useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(false)\n childProp?.props?.onBlur?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleClick = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onClick?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleContextMenu = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onContextMenu?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleFocus = useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onFocus?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleMouseEnter = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onMouseEnter?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleMouseLeave = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false)\n childProp?.props?.onMouseLeave?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n\n // Handle closing the tooltip when the mouse leaves the referenceElement\n useCloseOnMouseLeave({handleIsOpenChange, referenceElement, showTooltip, isInsideGroup})\n\n // Close when `disabled` changes to `true`\n useEffect(() => {\n if (disabled && showTooltip) handleIsOpenChange(false)\n }, [disabled, handleIsOpenChange, showTooltip])\n\n // Close when `content` changes to falsy\n useEffect(() => {\n if (!content && showTooltip) handleIsOpenChange(false)\n }, [content, handleIsOpenChange, showTooltip])\n\n const onWindowEscape = useEffectEvent(() => handleIsOpenChange(false, true))\n\n useEffect(() => {\n // If the user clicks on escape key, close the tooltip.\n if (!showTooltip) return\n\n function handleWindowKeyDown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n onWindowEscape()\n }\n }\n\n window.addEventListener('keydown', handleWindowKeyDown)\n\n // oxlint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('keydown', handleWindowKeyDown)\n }\n }, [showTooltip])\n\n // // Set the max width of the tooltip based on boundaries and portals\n useLayoutEffect(() => {\n // Get the maximum tooltip width (sans tooltip padding)\n // Tooltip width should never exceed the width of either any supplied boundary or portal element.\n // If both portal and boundary elements are provided, use the smaller width of the two.\n const availableWidths = [\n ...(boundaryElement ? [boundaryElement.offsetWidth] : []),\n portalElement?.offsetWidth || document.body.offsetWidth,\n ]\n\n // oxlint-disable-next-line react/set-state-in-effect\n setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2)\n }, [boundaryElement, portalElement])\n\n const setArrow = useCallback(\n (arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n update()\n },\n [update],\n )\n\n const setFloating = useCallback(\n (node: HTMLDivElement | null) => {\n ref.current = node\n refs.setFloating(node)\n },\n [refs],\n )\n\n const child = useMemo(() => {\n if (!childProp) return null\n\n return cloneElement(childProp, {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onClick: handleClick,\n onContextMenu: handleContextMenu,\n ref: setReferenceElement,\n })\n }, [\n childProp,\n handleBlur,\n handleClick,\n handleContextMenu,\n handleFocus,\n handleMouseEnter,\n handleMouseLeave,\n ])\n\n // If there's a child then we need to set the reference element to the cloned child ref\n // and if child changes we make sure to update or remove the reference element.\n useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [\n referenceElement,\n ])\n\n if (!child) return <></>\n\n if (disabled) return child\n\n const tooltip = (\n <Layer\n data-ui=\"Tooltip\"\n {...restProps}\n className={clsx(tooltipLayer, restProps.className)}\n ref={setFloating}\n style={{\n ...floatingStyles,\n maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : undefined,\n }}\n zOffset={zOffset}\n >\n <TooltipCard\n {...restProps}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n originX={originX}\n originY={originY}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n >\n {content}\n </TooltipCard>\n </Layer>\n )\n\n const tooltipNode = portalProp ? (\n <Portal __unstable_name={typeof portalProp === 'string' ? portalProp : undefined}>\n {tooltip}\n </Portal>\n ) : (\n tooltip\n )\n\n return (\n <>\n {/* the tooltip */}\n {animate ? (\n <AnimateActivity layoutMode=\"default\" mode={showTooltip ? 'visible' : 'hidden'}>\n {tooltipNode}\n </AnimateActivity>\n ) : (\n <Activity mode={showTooltip ? 'visible' : 'hidden'}>{tooltipNode}</Activity>\n )}\n\n {/* the referred element */}\n {child}\n </>\n )\n}\n\nfunction useMiddleware({\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n rootBoundary,\n}: {\n animate: boolean\n arrowProp: boolean\n arrowRef: React.RefObject<HTMLDivElement | null>\n boundaryElement: HTMLElement | null\n fallbackPlacements: Placement[]\n rootBoundary: RootBoundary\n}) {\n return useMemo(() => {\n const ret: Middleware[] = []\n\n // Flip the floating element when leaving the boundary box\n ret.push(\n flip({\n boundary: boundaryElement || undefined,\n fallbackPlacements,\n padding: DEFAULT_TOOLTIP_PADDING,\n rootBoundary,\n }),\n )\n\n // Define distance between reference and floating element\n ret.push(offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE}))\n\n // Shift the tooltip so its sits with the boundary element\n ret.push(\n shift({\n boundary: boundaryElement || undefined,\n rootBoundary,\n padding: DEFAULT_TOOLTIP_PADDING,\n }),\n )\n\n // Place arrow\n if (arrowProp) {\n ret.push(arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING}))\n }\n\n // Determine the origin to scale from.\n // Must be placed after `@sanity/ui/size` and `shift` middleware.\n if (animate) {\n ret.push(origin)\n }\n\n return ret\n }, [animate, arrowProp, arrowRef, boundaryElement, fallbackPlacements, rootBoundary])\n}\n\n/**\n * As `useEffectEvent` should never be passed to other components or hooks, this custom hook groups together the `useEffectEvent` and the `useEffect` hook using it.\n * @see https://19.react.dev/learn/separating-events-from-effects#reading-latest-props-and-state-with-effect-events:~:text=Never%20pass%20them%20to%20other%20components%20or%20Hooks\n */\nfunction useCloseOnMouseLeave({\n handleIsOpenChange,\n referenceElement,\n showTooltip,\n isInsideGroup,\n}: {\n handleIsOpenChange: (open: boolean, immediate?: boolean) => void\n referenceElement: HTMLElement | null\n showTooltip: boolean\n isInsideGroup: boolean\n}) {\n // Since we don't want the `mouseevent` events to be attached and removed if the `referenceElement` is changed\n // we use a \"effect event\" (https://19.react.dev/learn/separating-events-from-effects#reading-latest-props-and-state-with-effect-events)\n // in order to always see the latest `referenceElement` value inside the event handler itself.\n const onMouseMove = useEffectEvent((target: EventTarget | null, teardown: () => void) => {\n if (!referenceElement) return\n\n const isHoveringReference =\n referenceElement === target || (target instanceof Node && referenceElement.contains(target))\n\n if (!isHoveringReference) {\n handleIsOpenChange(false)\n // Allow removing the event listener eagerly, to avoid race conditions\n teardown()\n }\n })\n\n // Detect whether the mouse is moving outside of the reference element. This is sometimes\n // necessary, because the tooltip might not always close as it should (e.g. when clicking\n // the reference element triggers a CPU-heavy operation.)\n useEffect(() => {\n if (!showTooltip || isInsideGroup) return\n\n const handleMouseMove = (event: MouseEvent) => {\n onMouseMove(event.target, () => window.removeEventListener('mousemove', handleMouseMove))\n }\n\n window.addEventListener('mousemove', handleMouseMove)\n\n // oxlint-disable-next-line consistent-return\n return () => window.removeEventListener('mousemove', handleMouseMove)\n }, [isInsideGroup, showTooltip])\n}\n","import {useMemo} from 'react'\n\nimport {useDelayedState} from '../../../hooks/useDelayedState'\nimport {Delay} from '../../types'\nimport {TooltipDelayGroupContext} from './tooltipDelayGroupContext'\nimport {TooltipDelayGroupContextValue} from './types'\n\n/**\n * @public\n * */\nexport interface TooltipDelayGroupProviderProps {\n children?: React.ReactNode\n /**\n * Handles the delays to open or close a tooltip inside a group\n *\n * If only a `number` is passed, it will be used for both opening and closing.\n *\n * If an object `{open: number; close:number}` is passed, it can be used to set different delays for each action.\n *\n * @public\n */\n delay: Delay\n}\n\n/**\n * @public\n * Provides context for a group of tooltip elements that should share a delay\n * which temporarily becomes 1 ms after the first floating element of the group opens.\n */\nexport function TooltipDelayGroupProvider(\n props: TooltipDelayGroupProviderProps,\n): React.JSX.Element {\n const {children, delay} = props\n const [isGroupActive, setIsGroupActive] = useDelayedState(false)\n const [openTooltipId, setOpenTooltipId] = useDelayedState<string | null>(null)\n\n const openDelay = typeof delay === 'number' ? delay : delay?.open || 0\n const closeDelay = typeof delay === 'number' ? delay : delay?.close || 0\n\n const value: TooltipDelayGroupContextValue = useMemo(\n () => ({\n setIsGroupActive: setIsGroupActive,\n openTooltipId: openTooltipId,\n setOpenTooltipId: setOpenTooltipId,\n // When the group is active, we want the next tooltip to open immediately.\n openDelay: isGroupActive ? 1 : openDelay,\n closeDelay: closeDelay,\n }),\n [closeDelay, isGroupActive, openDelay, openTooltipId, setIsGroupActive, setOpenTooltipId],\n )\n\n return (\n <TooltipDelayGroupContext.Provider value={value}>{children}</TooltipDelayGroupContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAKA,SAAgB,gBACd,cAC6D;eACvD,CAAC,OAAO,YAAY,SAAS,YAAY,GACzC,gBAAgB,OAAmC,KAAA,CAAS,GAEhCA;qDAAC,MAAA,WAA8B,UAAmB;EAClF,IAAM,eAAe;GACnB,SAAS,SAAS;EACpB;EA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AM,mBAAmB,UAAsB;GAC7C,YAAY,MAAM,cAAc,OAAO,oBAAoB,aAAa,eAAe,CAAC;EAC1F;EAKA,OAHA,OAAO,iBAAiB,aAAa,eAAe,SAGvC,OAAO,oBAAoB,aAAa,eAAe;CACtE,GAVsB,EAAA,KAAA,eAGlB,EAAA,KAAA,aAHG,EAAA,KAAA;CAUJC,IAAAA;CAXH,AAWI,EAAA,OAAA,iBAAA,EAAA,OAAe,eAAhB,KAAA,CAAC,eAAe,WAAW,GAA1B,EAAA,KAAA,eAAe,EAAA,KAAA,qCAXnB,UAAUD,IAWPC,EAA4B;AACjC;;;;;;AC/dA,SAAgB,0BACd,OACmB;eACb,EAAC,UAAU,UAAS,OACpB,CAAC,eAAe,oBAAoB,gBAAgB,EAAK,GACzD,CAAC,eAAe,oBAAoB,gBAA+B,IAAI,GAEvE,YAAY,OAAO,SAAU,WAAW,QAAQ,OAAO,QAAQ,GAC/D,aAAa,OAAO,SAAU,WAAW,QAAQ,OAAO,SAAS,GAQxD,KAAA,gBAAgB,IAAI,WAL1BG;CAMO,AAAA,EAAA,OAAA,cAAA,EAAA,OAJG,iBAAA,EAAA,OADG,oBAAA,EAAA,OAEA,oBAAA,EAAA,OAEPC,MALN,KAAA;EACa;EACH;EACG;EAElB,WAAWA;EACC;CACd,GADc,EAAA,KAAA,YAJG,EAAA,KAAA,eADG,EAAA,KAAA,kBAEA,EAAA,KAAA,kBAEPA,EAAAA,KAAAA;CANf,IAAM,QAAuCC,IAa3CC;CADF,OACoD,EAAA,OAAA,YAAA,EAAA,OAAR,SAA1C,KAAA,oBAACC,yBAAAA,UAAD;EAA0C;EAAQ;CAA4C,CAAA,GAA5C,EAAA,KAAA,UAAR,EAAA,KAAA,+BAA1CD;AAEJ"}
1
+ {"version":3,"file":"tooltip.js","names":["(nextState: SetStateAction<S>, delay?: number) => {\n const action = () => {\n setState(nextState)\n }\n\n // A new state change has been initiated, cancel the previous one.\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n delayedAction.current = undefined\n }\n\n if (!delay) return action()\n delayedAction.current = setTimeout(action, delay)\n }","useCallback((nextState: SetStateAction<S>, delay?: number) => {\n const action = () => {\n setState(nextState)\n }\n\n // A new state change has been initiated, cancel the previous one.\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n delayedAction.current = undefined\n }\n\n if (!delay) return action()\n delayedAction.current = setTimeout(action, delay)\n }, [])","() => {\n return () => {\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n }\n }\n }","[]","[state, onStateChange]","_c","getTransformOrigin(originX, originY)","{\n transformOrigin: getTransformOrigin(originX, originY),\n willChange: animate ? 'transform' : undefined,\n ...style,\n }","animate ? 'transform' : undefined","useMemo(\n () => ({\n transformOrigin: getTransformOrigin(originX, originY),\n willChange: animate ? 'transform' : undefined,\n ...style,\n }),\n [animate, originX, originY, style],\n )","{\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }","arrowX !== null ? arrowX : undefined","arrowY !== null ? arrowY : undefined","useMemo(\n () => ({\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }),\n [arrowX, arrowY],\n )","clsx(tooltipCard, className)","arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_TOOLTIP_ARROW_WIDTH}\n height={DEFAULT_TOOLTIP_ARROW_HEIGHT}\n radius={DEFAULT_TOOLTIP_ARROW_RADIUS}\n />\n )","<MotionCard\n className={clsx(tooltipCard, className)}\n data-ui=\"Tooltip__card\"\n {...restProps}\n data-placement={placement}\n padding={padding}\n radius={radius}\n ref={ref}\n scheme={scheme}\n shadow={shadow}\n style={rootStyle}\n {...(animate ? POPOVER_MOTION_PROPS : undefined)}\n >\n {children}\n\n {arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_TOOLTIP_ARROW_WIDTH}\n height={DEFAULT_TOOLTIP_ARROW_HEIGHT}\n radius={DEFAULT_TOOLTIP_ARROW_RADIUS}\n />\n )}\n </MotionCard>","animate ? POPOVER_MOTION_PROPS : undefined","_c","_animate = false","arrowProp = false","placementProp = 'bottom'","padding = 2","radius = 2","shadow = 2","_getArrayProp(fallbackPlacementsProp)","() => ref.current","{\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n rootBoundary,\n }","{reference: referenceElement}","{\n middleware,\n placement: placementProp,\n whileElementsMounted: autoUpdate,\n elements: {reference: referenceElement},\n }","delayGroupContext || {}","(open: boolean, immediate?: boolean) => {\n if (isInsideGroup) {\n // When it's inside a group, the open or close status will be handled by the group.\n if (open) {\n const groupedOpenDelay = immediate ? 0 : openDelay\n\n setIsGroupActive?.(open, groupedOpenDelay)\n setOpenTooltipId?.(tooltipId, groupedOpenDelay)\n } else {\n const minimumGroupDeactivateDelay = 200 // We should provide some delay to allow the user to reach the next tooltip.\n const groupDeactivateDelay =\n closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay\n\n setIsGroupActive?.(open, groupDeactivateDelay)\n setOpenTooltipId?.(null, immediate ? 0 : closeDelay)\n }\n } else {\n const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay\n\n // When it's not inside a group, the open or close status will be handled by the tooltip itself.\n setIsOpen(open, standaloneDelay)\n }\n }","useCallback(\n (open: boolean, immediate?: boolean) => {\n if (isInsideGroup) {\n // When it's inside a group, the open or close status will be handled by the group.\n if (open) {\n const groupedOpenDelay = immediate ? 0 : openDelay\n\n setIsGroupActive?.(open, groupedOpenDelay)\n setOpenTooltipId?.(tooltipId, groupedOpenDelay)\n } else {\n const minimumGroupDeactivateDelay = 200 // We should provide some delay to allow the user to reach the next tooltip.\n const groupDeactivateDelay =\n closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay\n\n setIsGroupActive?.(open, groupDeactivateDelay)\n setOpenTooltipId?.(null, immediate ? 0 : closeDelay)\n }\n } else {\n const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay\n\n // When it's not inside a group, the open or close status will be handled by the tooltip itself.\n setIsOpen(open, standaloneDelay)\n }\n },\n [\n isInsideGroup,\n openDelay,\n setIsGroupActive,\n setOpenTooltipId,\n tooltipId,\n closeDelay,\n setIsOpen,\n ],\n )","(e: FocusEvent) => {\n handleIsOpenChange(false)\n childProp?.props?.onBlur?.(e)\n }","props","useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(false)\n childProp?.props?.onBlur?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onClick?.(e)\n }","e","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onClick?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onContextMenu?.(e)\n }","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onContextMenu?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: FocusEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onFocus?.(e)\n }","useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onFocus?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onMouseEnter?.(e)\n }","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onMouseEnter?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","(e: MouseEvent) => {\n handleIsOpenChange(false)\n childProp?.props?.onMouseLeave?.(e)\n }","useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false)\n childProp?.props?.onMouseLeave?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )","{handleIsOpenChange, referenceElement, showTooltip, isInsideGroup}","() => {\n if (disabled && showTooltip) handleIsOpenChange(false)\n }","[disabled, handleIsOpenChange, showTooltip]","() => {\n if (!content && showTooltip) handleIsOpenChange(false)\n }","[content, handleIsOpenChange, showTooltip]","() => handleIsOpenChange(false, true)","() => {\n // If the user clicks on escape key, close the tooltip.\n if (!showTooltip) return\n\n function handleWindowKeyDown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n onWindowEscape()\n }\n }\n\n window.addEventListener('keydown', handleWindowKeyDown)\n\n // oxlint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('keydown', handleWindowKeyDown)\n }\n }","[showTooltip]","() => {\n setTooltipMaxWidth(\n measureAvailableWidth(boundaryElement, portalElement) - DEFAULT_TOOLTIP_PADDING * 2,\n )\n }","() => {\n if (showTooltip && !disabled) measureTooltipMaxWidth()\n }","[disabled, showTooltip]","(arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n update()\n }","useCallback(\n (arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n update()\n },\n [update],\n )","(node: HTMLDivElement | null) => {\n ref.current = node\n refs.setFloating(node)\n }","useCallback(\n (node: HTMLDivElement | null) => {\n ref.current = node\n refs.setFloating(node)\n },\n [refs],\n )","useMemo(() => {\n if (!childProp) return null\n\n return cloneElement(childProp, {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onClick: handleClick,\n onContextMenu: handleContextMenu,\n ref: setReferenceElement,\n })\n }, [\n childProp,\n handleBlur,\n handleClick,\n handleContextMenu,\n handleFocus,\n handleMouseEnter,\n handleMouseLeave,\n ])","cloneElement(childProp, {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onClick: handleClick,\n onContextMenu: handleContextMenu,\n ref: setReferenceElement,\n })","childProp ? getElementRef(childProp) : null","() => referenceElement","[\n referenceElement,\n ]","<></>","{\n ...floatingStyles,\n maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : undefined,\n }","tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : undefined","<TooltipCard\n {...restProps}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n originX={originX}\n originY={originY}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n >\n {content}\n </TooltipCard>","<Layer\n data-ui=\"Tooltip\"\n {...restProps}\n className={clsx(tooltipLayer, restProps.className)}\n ref={setFloating}\n style={{\n ...floatingStyles,\n maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : undefined,\n }}\n zOffset={zOffset}\n >\n <TooltipCard\n {...restProps}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n originX={originX}\n originY={originY}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n >\n {content}\n </TooltipCard>\n </Layer>","Layer","clsx(tooltipLayer, restProps.className)","\"Tooltip\"","portalProp ? (\n <Portal __unstable_name={typeof portalProp === 'string' ? portalProp : undefined}>\n {tooltip}\n </Portal>\n ) : (\n tooltip\n )","animate ? (\n <AnimateActivity layoutMode=\"default\" mode={showTooltip ? 'visible' : 'hidden'}>\n {tooltipNode}\n </AnimateActivity>\n ) : (\n <Activity mode={showTooltip ? 'visible' : 'hidden'}>{tooltipNode}</Activity>\n )","<>\n {/* the tooltip */}\n {animate ? (\n <AnimateActivity layoutMode=\"default\" mode={showTooltip ? 'visible' : 'hidden'}>\n {tooltipNode}\n </AnimateActivity>\n ) : (\n <Activity mode={showTooltip ? 'visible' : 'hidden'}>{tooltipNode}</Activity>\n )}\n\n {/* the referred element */}\n {child}\n </>","{\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n rootBoundary,\n}: {\n animate: boolean\n arrowProp: boolean\n arrowRef: React.RefObject<HTMLDivElement | null>\n boundaryElement: HTMLElement | null\n fallbackPlacements: Placement[]\n rootBoundary: RootBoundary\n}","flip({\n boundary: boundaryElement || undefined,\n fallbackPlacements,\n padding: DEFAULT_TOOLTIP_PADDING,\n rootBoundary,\n })","boundaryElement || undefined","offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE})","shift({\n boundary: boundaryElement || undefined,\n rootBoundary,\n padding: DEFAULT_TOOLTIP_PADDING,\n })","arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING})","useMemo(() => {\n const ret: Middleware[] = []\n\n // Flip the floating element when leaving the boundary box\n ret.push(\n flip({\n boundary: boundaryElement || undefined,\n fallbackPlacements,\n padding: DEFAULT_TOOLTIP_PADDING,\n rootBoundary,\n }),\n )\n\n // Define distance between reference and floating element\n ret.push(offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE}))\n\n // Shift the tooltip so its sits with the boundary element\n ret.push(\n shift({\n boundary: boundaryElement || undefined,\n rootBoundary,\n padding: DEFAULT_TOOLTIP_PADDING,\n }),\n )\n\n // Place arrow\n if (arrowProp) {\n ret.push(arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING}))\n }\n\n // Determine the origin to scale from.\n // Must be placed after `@sanity/ui/size` and `shift` middleware.\n if (animate) {\n ret.push(origin)\n }\n\n return ret\n }, [animate, arrowProp, arrowRef, boundaryElement, fallbackPlacements, rootBoundary])","{\n handleIsOpenChange,\n referenceElement,\n showTooltip,\n isInsideGroup,\n}: {\n handleIsOpenChange: (open: boolean, immediate?: boolean) => void\n referenceElement: HTMLElement | null\n showTooltip: boolean\n isInsideGroup: boolean\n}","(target: EventTarget | null, teardown: () => void) => {\n if (!referenceElement) return\n\n const isHoveringReference =\n referenceElement === target || (target instanceof Node && referenceElement.contains(target))\n\n if (!isHoveringReference) {\n handleIsOpenChange(false)\n // Allow removing the event listener eagerly, to avoid race conditions\n teardown()\n }\n }","() => {\n if (!showTooltip || isInsideGroup) return\n\n const handleMouseMove = (event: MouseEvent) => {\n onMouseMove(event.target, () => window.removeEventListener('mousemove', handleMouseMove))\n }\n\n window.addEventListener('mousemove', handleMouseMove)\n\n // oxlint-disable-next-line consistent-return\n return () => window.removeEventListener('mousemove', handleMouseMove)\n }","[isInsideGroup, showTooltip]","_c","_Fragment","{\n setIsGroupActive: setIsGroupActive,\n openTooltipId: openTooltipId,\n setOpenTooltipId: setOpenTooltipId,\n // When the group is active, we want the next tooltip to open immediately.\n openDelay: isGroupActive ? 1 : openDelay,\n closeDelay: closeDelay,\n }","isGroupActive ? 1 : openDelay","useMemo(\n () => ({\n setIsGroupActive: setIsGroupActive,\n openTooltipId: openTooltipId,\n setOpenTooltipId: setOpenTooltipId,\n // When the group is active, we want the next tooltip to open immediately.\n openDelay: isGroupActive ? 1 : openDelay,\n closeDelay: closeDelay,\n }),\n [closeDelay, isGroupActive, openDelay, openTooltipId, setIsGroupActive, setOpenTooltipId],\n )","<TooltipDelayGroupContext.Provider value={value}>{children}</TooltipDelayGroupContext.Provider>","TooltipDelayGroupContext.Provider","_c","\"top\"","\"bottom\"","\"left\"","\"right\""],"sources":["../src/core/hooks/useDelayedState.ts","../src/core/primitives/tooltip/constants.ts","../src/core/primitives/tooltip/tooltip.css.ts","../src/core/primitives/tooltip/tooltipCard.tsx","../src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupContext.tsx","../src/core/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts","../src/core/primitives/tooltip/tooltip.tsx","../src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx"],"sourcesContent":["import {SetStateAction, useCallback, useEffect, useRef, useState} from 'react'\n\n/**\n * @beta\n */\nexport function useDelayedState<S>(\n initialState: S | (() => S),\n): [S, (nextState: SetStateAction<S>, delay?: number) => void] {\n const [state, setState] = useState(initialState)\n const delayedAction = useRef<NodeJS.Timeout | undefined>(undefined)\n\n const onStateChange = useCallback((nextState: SetStateAction<S>, delay?: number) => {\n const action = () => {\n setState(nextState)\n }\n\n // A new state change has been initiated, cancel the previous one.\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n delayedAction.current = undefined\n }\n\n if (!delay) return action()\n delayedAction.current = setTimeout(action, delay)\n }, [])\n\n useEffect(() => {\n return () => {\n if (delayedAction.current) {\n clearTimeout(delayedAction.current)\n }\n }\n }, [])\n\n return [state, onStateChange]\n}\n","import {Placement} from '@floating-ui/react-dom'\n\nexport const DEFAULT_TOOLTIP_ARROW_WIDTH = 15\nexport const DEFAULT_TOOLTIP_ARROW_HEIGHT = 6\nexport const DEFAULT_TOOLTIP_ARROW_RADIUS = 2\n\nexport const DEFAULT_TOOLTIP_DISTANCE = 4\nexport const DEFAULT_TOOLTIP_PADDING = 4\n\nexport const DEFAULT_FALLBACK_PLACEMENTS: Record<Placement, Placement[]> = {\n 'top': ['top-end', 'top-start', 'bottom', 'left', 'right'],\n 'top-start': ['top', 'top-end', 'bottom-start', 'left-start', 'right-start'],\n 'top-end': ['top', 'top-start', 'bottom-end', 'left-end', 'right-end'],\n 'bottom': ['bottom-end', 'bottom-start', 'top', 'left', 'right'],\n 'bottom-start': ['bottom', 'bottom-end', 'top-start', 'left-start', 'right-start'],\n 'bottom-end': ['bottom', 'bottom-start', 'top-end', 'left-end', 'right-end'],\n 'left': ['left-end', 'left-start', 'right', 'top', 'bottom'],\n 'left-start': ['left', 'left-end', 'right-start', 'top-start', 'bottom-start'],\n 'left-end': ['left', 'left-start', 'right-end', 'top-end', 'bottom-end'],\n 'right': ['right-end', 'right-start', 'left', 'top', 'bottom'],\n 'right-start': ['right', 'right-end', 'left-start', 'top-start', 'bottom-start'],\n 'right-end': ['right', 'right-start', 'left-end', 'top-end', 'bottom-end'],\n}\n","import {style} from '@vanilla-extract/css'\n\nexport const tooltipLayer = style({\n pointerEvents: 'none',\n})\n\nexport const tooltipCard = style({\n willChange: 'transform',\n})\n","import {clsx} from 'clsx/lite'\nimport {motion} from 'motion/react'\nimport React, {CSSProperties, useMemo} from 'react'\n\nimport {ThemeColorSchemeKey} from '../../../theme/system/color/_system'\nimport {POPOVER_MOTION_PROPS} from '../../constants'\nimport {getTransformOrigin} from '../../middleware/origin'\nimport {Placement} from '../../types/placement'\nimport {Radius} from '../../types/radius'\nimport {Arrow} from '../../utils/arrow/arrow'\nimport {Card} from '../card/card'\nimport {\n DEFAULT_TOOLTIP_ARROW_HEIGHT,\n DEFAULT_TOOLTIP_ARROW_RADIUS,\n DEFAULT_TOOLTIP_ARROW_WIDTH,\n} from './constants'\n\nimport {tooltipCard} from './tooltip.css'\n\nconst MotionCard = motion.create(Card)\n\n/**\n * @internal\n */\nexport function TooltipCard(\n props: {\n animate?: boolean\n arrow: boolean\n arrowRef: React.Ref<HTMLDivElement>\n arrowX?: number\n arrowY?: number\n originX?: number\n originY?: number\n padding?: number | number[]\n placement?: Placement\n radius?: Radius | Radius[]\n scheme?: ThemeColorSchemeKey\n shadow?: number | number[]\n } & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'width'>,\n) {\n const {\n animate,\n arrow,\n arrowRef,\n arrowX,\n arrowY,\n children,\n className,\n originX,\n originY,\n padding,\n placement,\n radius,\n ref,\n scheme,\n shadow,\n style,\n ...restProps\n } = props\n\n const rootStyle: CSSProperties = useMemo(\n () => ({\n transformOrigin: getTransformOrigin(originX, originY),\n willChange: animate ? 'transform' : undefined,\n ...style,\n }),\n [animate, originX, originY, style],\n )\n\n const arrowStyle: CSSProperties = useMemo(\n () => ({\n left: arrowX !== null ? arrowX : undefined,\n top: arrowY !== null ? arrowY : undefined,\n right: undefined,\n bottom: undefined,\n }),\n [arrowX, arrowY],\n )\n\n return (\n <MotionCard\n className={clsx(tooltipCard, className)}\n data-ui=\"Tooltip__card\"\n {...restProps}\n data-placement={placement}\n padding={padding}\n radius={radius}\n ref={ref}\n scheme={scheme}\n shadow={shadow}\n style={rootStyle}\n {...(animate ? POPOVER_MOTION_PROPS : undefined)}\n >\n {children}\n\n {arrow && (\n <Arrow\n ref={arrowRef}\n style={arrowStyle}\n width={DEFAULT_TOOLTIP_ARROW_WIDTH}\n height={DEFAULT_TOOLTIP_ARROW_HEIGHT}\n radius={DEFAULT_TOOLTIP_ARROW_RADIUS}\n />\n )}\n </MotionCard>\n )\n}\n","import {createGlobalScopedContext} from '../../../lib/createGlobalScopedContext'\nimport {TooltipDelayGroupContextValue} from './types'\n\n/**\n * @beta\n */\nexport const TooltipDelayGroupContext =\n createGlobalScopedContext<TooltipDelayGroupContextValue | null>(\n '@sanity/ui/context/tooltipDelayGroup',\n null,\n )\n","import {useContext} from 'react'\n\nimport {TooltipDelayGroupContext} from './tooltipDelayGroupContext'\nimport {TooltipDelayGroupContextValue} from './types'\n\n/**\n * @beta\n */\nexport function useTooltipDelayGroup(): TooltipDelayGroupContextValue | null {\n const value = useContext(TooltipDelayGroupContext)\n\n return value\n}\n","import {\n arrow,\n autoUpdate,\n flip,\n type Middleware,\n offset,\n type RootBoundary,\n shift,\n useFloating,\n} from '@floating-ui/react-dom'\nimport {clsx} from 'clsx/lite'\nimport {\n Activity,\n cloneElement,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n// TODO: switch to `useEffectEvent` from `react` once\n// https://github.com/facebook/react/issues/34818 is fixed in the lowest React\n// version we support: on React 19.2 the native hook never sees values past\n// the first render when the calling component is wrapped in `forwardRef` or\n// `memo`, and consumers may wrap `Tooltip` in `memo`.\nimport {useEffectEvent} from 'use-effect-event'\n\nimport type {ThemeColorSchemeKey} from '../../../theme/system/color/_system'\nimport {useDelayedState} from '../../hooks/useDelayedState'\nimport {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'\nimport {origin} from '../../middleware/origin'\nimport {_getArrayProp} from '../../styles/helpers'\nimport {useTheme_v2} from '../../theme/useTheme'\nimport type {Placement} from '../../types/placement'\nimport {AnimateActivity} from '../../utils/animateActivity'\nimport {useBoundaryElement} from '../../utils/boundaryElement/useBoundaryElement'\nimport {getElementRef} from '../../utils/getElementRef'\nimport {Layer, type LayerProps} from '../../utils/layer/layer'\nimport {Portal} from '../../utils/portal/portal'\nimport {usePortal} from '../../utils/portal/usePortal'\nimport type {Delay} from '../types'\nimport {\n DEFAULT_FALLBACK_PLACEMENTS,\n DEFAULT_TOOLTIP_DISTANCE,\n DEFAULT_TOOLTIP_PADDING,\n} from './constants'\nimport {TooltipCard} from './tooltipCard'\nimport {useTooltipDelayGroup} from './tooltipDelayGroup/useTooltipDelayGroup'\n\nimport {tooltipLayer} from './tooltip.css'\n\n/**\n * @public\n */\nexport interface TooltipProps extends Omit<LayerProps, 'as'> {\n /** @deprecated Use `fallbackPlacements` instead. */\n allowedAutoPlacements?: never\n arrow?: boolean\n boundaryElement?: HTMLElement | null\n children?: React.JSX.Element\n content?: React.ReactNode\n disabled?: boolean\n fallbackPlacements?: Placement[]\n padding?: number | number[]\n placement?: Placement\n /** Whether or not to render the tooltip in a portal element. */\n portal?: boolean | string\n radius?: number | number[]\n scheme?: ThemeColorSchemeKey\n shadow?: number | number[]\n /**\n * Adds a delay to open or close the tooltip.\n *\n * If only a `number` is passed, it will be used for both opening and closing.\n *\n * If an object `{open: number; close:number}` is passed, it can be used to set different delays for each action.\n *\n * @public\n * @defaultValue 0\n */\n delay?: Delay\n /**\n * Whether the tooltip should animate in and out.\n *\n * @beta\n * @defaultValue false\n */\n animate?: boolean\n}\n\n/**\n * Tooltips display information when hovering, focusing or tapping.\n *\n * @public\n */\nexport function Tooltip(\n props: TooltipProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content'>,\n) {\n const boundaryElementContext = useBoundaryElement()\n const {layer} = useTheme_v2()\n const {\n animate: _animate = false,\n arrow: arrowProp = false,\n boundaryElement: _boundaryElement,\n children: childProp,\n content,\n disabled,\n fallbackPlacements: _fallbackPlacementsProp,\n padding = 2,\n placement: placementProp = 'bottom',\n portal: portalProp,\n radius = 2,\n ref: forwardedRef,\n scheme,\n shadow = 2,\n zOffset: _zOffset,\n delay,\n ...restProps\n } = props\n const boundaryElement = _boundaryElement ?? boundaryElementContext?.element\n const fallbackPlacementsProp =\n _fallbackPlacementsProp ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? 'bottom']\n const zOffset = _zOffset ?? layer.tooltip.zOffset\n const prefersReducedMotion = usePrefersReducedMotion()\n const animate = prefersReducedMotion ? false : _animate\n const fallbackPlacements = _getArrayProp(fallbackPlacementsProp)\n const ref = useRef<HTMLDivElement | null>(null)\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null)\n const arrowRef = useRef<HTMLDivElement | null>(null)\n const rootBoundary: RootBoundary = 'viewport'\n const [tooltipMaxWidth, setTooltipMaxWidth] = useState(0)\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => ref.current)\n\n const portal = usePortal()\n const portalElement =\n typeof portalProp === 'string' ? portal.elements?.[portalProp] || null : portal.element\n\n const middleware = useMiddleware({\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n rootBoundary,\n })\n\n const {floatingStyles, placement, middlewareData, refs, update} = useFloating({\n middleware,\n placement: placementProp,\n whileElementsMounted: autoUpdate,\n elements: {reference: referenceElement},\n })\n\n const arrowX = middlewareData.arrow?.x\n const arrowY = middlewareData.arrow?.y\n\n const originX = middlewareData['@sanity/ui/origin']?.originX\n const originY = middlewareData['@sanity/ui/origin']?.originY\n\n const tooltipId = useId()\n const [isOpen, setIsOpen] = useDelayedState(false)\n const delayGroupContext = useTooltipDelayGroup()\n const {setIsGroupActive, setOpenTooltipId} = delayGroupContext || {}\n const showTooltip = isOpen || delayGroupContext?.openTooltipId === tooltipId\n\n const isInsideGroup = delayGroupContext !== null\n const openDelayProp = typeof delay === 'number' ? delay : delay?.open || 0\n const closeDelayProp = typeof delay === 'number' ? delay : delay?.close || 0\n\n const openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp\n const closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp\n\n const handleIsOpenChange = useCallback(\n (open: boolean, immediate?: boolean) => {\n if (isInsideGroup) {\n // When it's inside a group, the open or close status will be handled by the group.\n if (open) {\n const groupedOpenDelay = immediate ? 0 : openDelay\n\n setIsGroupActive?.(open, groupedOpenDelay)\n setOpenTooltipId?.(tooltipId, groupedOpenDelay)\n } else {\n const minimumGroupDeactivateDelay = 200 // We should provide some delay to allow the user to reach the next tooltip.\n const groupDeactivateDelay =\n closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay\n\n setIsGroupActive?.(open, groupDeactivateDelay)\n setOpenTooltipId?.(null, immediate ? 0 : closeDelay)\n }\n } else {\n const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay\n\n // When it's not inside a group, the open or close status will be handled by the tooltip itself.\n setIsOpen(open, standaloneDelay)\n }\n },\n [\n isInsideGroup,\n openDelay,\n setIsGroupActive,\n setOpenTooltipId,\n tooltipId,\n closeDelay,\n setIsOpen,\n ],\n )\n\n const handleBlur = useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(false)\n childProp?.props?.onBlur?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleClick = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onClick?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleContextMenu = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false, true)\n childProp?.props.onContextMenu?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleFocus = useCallback(\n (e: FocusEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onFocus?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleMouseEnter = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(true)\n childProp?.props?.onMouseEnter?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n const handleMouseLeave = useCallback(\n (e: MouseEvent) => {\n handleIsOpenChange(false)\n childProp?.props?.onMouseLeave?.(e)\n },\n [childProp?.props, handleIsOpenChange],\n )\n\n // Handle closing the tooltip when the mouse leaves the referenceElement\n useCloseOnMouseLeave({handleIsOpenChange, referenceElement, showTooltip, isInsideGroup})\n\n // Close when `disabled` changes to `true`\n useEffect(() => {\n if (disabled && showTooltip) handleIsOpenChange(false)\n }, [disabled, handleIsOpenChange, showTooltip])\n\n // Close when `content` changes to falsy\n useEffect(() => {\n if (!content && showTooltip) handleIsOpenChange(false)\n }, [content, handleIsOpenChange, showTooltip])\n\n const onWindowEscape = useEffectEvent(() => handleIsOpenChange(false, true))\n\n useEffect(() => {\n // If the user clicks on escape key, close the tooltip.\n if (!showTooltip) return\n\n function handleWindowKeyDown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n onWindowEscape()\n }\n }\n\n window.addEventListener('keydown', handleWindowKeyDown)\n\n // oxlint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('keydown', handleWindowKeyDown)\n }\n }, [showTooltip])\n\n // Set the max width of the tooltip based on boundaries and portals (sans tooltip padding).\n // Measuring forces a synchronous layout, so it only happens when the tooltip opens — not on\n // mount of a closed tooltip, not when the boundary or portal element changes, and never during\n // render. The effect event reads the latest elements without the effect depending on them.\n const measureTooltipMaxWidth = useEffectEvent(() => {\n setTooltipMaxWidth(\n measureAvailableWidth(boundaryElement, portalElement) - DEFAULT_TOOLTIP_PADDING * 2,\n )\n })\n\n // A disabled tooltip renders nothing, but hovering its child still flips `showTooltip` for the\n // one commit before the effect above closes it again, so it is gated out explicitly.\n useLayoutEffect(() => {\n if (showTooltip && !disabled) measureTooltipMaxWidth()\n }, [disabled, showTooltip])\n\n const setArrow = useCallback(\n (arrowEl: HTMLDivElement | null) => {\n arrowRef.current = arrowEl\n update()\n },\n [update],\n )\n\n const setFloating = useCallback(\n (node: HTMLDivElement | null) => {\n ref.current = node\n refs.setFloating(node)\n },\n [refs],\n )\n\n const child = useMemo(() => {\n if (!childProp) return null\n\n return cloneElement(childProp, {\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onClick: handleClick,\n onContextMenu: handleContextMenu,\n ref: setReferenceElement,\n })\n }, [\n childProp,\n handleBlur,\n handleClick,\n handleContextMenu,\n handleFocus,\n handleMouseEnter,\n handleMouseLeave,\n ])\n\n // If there's a child then we need to set the reference element to the cloned child ref\n // and if child changes we make sure to update or remove the reference element.\n useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [\n referenceElement,\n ])\n\n if (!child) return <></>\n\n if (disabled) return child\n\n const tooltip = (\n <Layer\n data-ui=\"Tooltip\"\n {...restProps}\n className={clsx(tooltipLayer, restProps.className)}\n ref={setFloating}\n style={{\n ...floatingStyles,\n maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : undefined,\n }}\n zOffset={zOffset}\n >\n <TooltipCard\n {...restProps}\n animate={animate}\n arrow={arrowProp}\n arrowRef={setArrow}\n arrowX={arrowX}\n arrowY={arrowY}\n originX={originX}\n originY={originY}\n padding={padding}\n placement={placement}\n radius={radius}\n ref={setFloating}\n scheme={scheme}\n shadow={shadow}\n >\n {content}\n </TooltipCard>\n </Layer>\n )\n\n const tooltipNode = portalProp ? (\n <Portal __unstable_name={typeof portalProp === 'string' ? portalProp : undefined}>\n {tooltip}\n </Portal>\n ) : (\n tooltip\n )\n\n return (\n <>\n {/* the tooltip */}\n {animate ? (\n <AnimateActivity layoutMode=\"default\" mode={showTooltip ? 'visible' : 'hidden'}>\n {tooltipNode}\n </AnimateActivity>\n ) : (\n <Activity mode={showTooltip ? 'visible' : 'hidden'}>{tooltipNode}</Activity>\n )}\n\n {/* the referred element */}\n {child}\n </>\n )\n}\n\n/**\n * Tooltip width should never exceed the width of either any supplied boundary or portal element.\n * If both portal and boundary elements are provided, use the smaller width of the two.\n *\n * Kept at module scope on purpose: `offsetWidth` forces a synchronous layout, and the React\n * Compiler (which the package build runs) lifts a member expression on an element captured by a\n * component callback — `portalElement?.offsetWidth` — into a memo dependency evaluated during\n * render. A plain function call on the elements gives it nothing to lift.\n */\nfunction measureAvailableWidth(\n boundaryElement: HTMLElement | null,\n portalElement: HTMLElement | null,\n): number {\n const availableWidths = [\n ...(boundaryElement ? [boundaryElement.offsetWidth] : []),\n portalElement?.offsetWidth || document.body.offsetWidth,\n ]\n\n return Math.min(...availableWidths)\n}\n\nfunction useMiddleware({\n animate,\n arrowProp,\n arrowRef,\n boundaryElement,\n fallbackPlacements,\n rootBoundary,\n}: {\n animate: boolean\n arrowProp: boolean\n arrowRef: React.RefObject<HTMLDivElement | null>\n boundaryElement: HTMLElement | null\n fallbackPlacements: Placement[]\n rootBoundary: RootBoundary\n}) {\n return useMemo(() => {\n const ret: Middleware[] = []\n\n // Flip the floating element when leaving the boundary box\n ret.push(\n flip({\n boundary: boundaryElement || undefined,\n fallbackPlacements,\n padding: DEFAULT_TOOLTIP_PADDING,\n rootBoundary,\n }),\n )\n\n // Define distance between reference and floating element\n ret.push(offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE}))\n\n // Shift the tooltip so its sits with the boundary element\n ret.push(\n shift({\n boundary: boundaryElement || undefined,\n rootBoundary,\n padding: DEFAULT_TOOLTIP_PADDING,\n }),\n )\n\n // Place arrow\n if (arrowProp) {\n ret.push(arrow({element: arrowRef, padding: DEFAULT_TOOLTIP_PADDING}))\n }\n\n // Determine the origin to scale from.\n // Must be placed after `@sanity/ui/size` and `shift` middleware.\n if (animate) {\n ret.push(origin)\n }\n\n return ret\n }, [animate, arrowProp, arrowRef, boundaryElement, fallbackPlacements, rootBoundary])\n}\n\n/**\n * As `useEffectEvent` should never be passed to other components or hooks, this custom hook groups together the `useEffectEvent` and the `useEffect` hook using it.\n * @see https://19.react.dev/learn/separating-events-from-effects#reading-latest-props-and-state-with-effect-events:~:text=Never%20pass%20them%20to%20other%20components%20or%20Hooks\n */\nfunction useCloseOnMouseLeave({\n handleIsOpenChange,\n referenceElement,\n showTooltip,\n isInsideGroup,\n}: {\n handleIsOpenChange: (open: boolean, immediate?: boolean) => void\n referenceElement: HTMLElement | null\n showTooltip: boolean\n isInsideGroup: boolean\n}) {\n // Since we don't want the `mouseevent` events to be attached and removed if the `referenceElement` is changed\n // we use a \"effect event\" (https://19.react.dev/learn/separating-events-from-effects#reading-latest-props-and-state-with-effect-events)\n // in order to always see the latest `referenceElement` value inside the event handler itself.\n const onMouseMove = useEffectEvent((target: EventTarget | null, teardown: () => void) => {\n if (!referenceElement) return\n\n const isHoveringReference =\n referenceElement === target || (target instanceof Node && referenceElement.contains(target))\n\n if (!isHoveringReference) {\n handleIsOpenChange(false)\n // Allow removing the event listener eagerly, to avoid race conditions\n teardown()\n }\n })\n\n // Detect whether the mouse is moving outside of the reference element. This is sometimes\n // necessary, because the tooltip might not always close as it should (e.g. when clicking\n // the reference element triggers a CPU-heavy operation.)\n useEffect(() => {\n if (!showTooltip || isInsideGroup) return\n\n const handleMouseMove = (event: MouseEvent) => {\n onMouseMove(event.target, () => window.removeEventListener('mousemove', handleMouseMove))\n }\n\n window.addEventListener('mousemove', handleMouseMove)\n\n // oxlint-disable-next-line consistent-return\n return () => window.removeEventListener('mousemove', handleMouseMove)\n }, [isInsideGroup, showTooltip])\n}\n","import {useMemo} from 'react'\n\nimport {useDelayedState} from '../../../hooks/useDelayedState'\nimport {Delay} from '../../types'\nimport {TooltipDelayGroupContext} from './tooltipDelayGroupContext'\nimport {TooltipDelayGroupContextValue} from './types'\n\n/**\n * @public\n * */\nexport interface TooltipDelayGroupProviderProps {\n children?: React.ReactNode\n /**\n * Handles the delays to open or close a tooltip inside a group\n *\n * If only a `number` is passed, it will be used for both opening and closing.\n *\n * If an object `{open: number; close:number}` is passed, it can be used to set different delays for each action.\n *\n * @public\n */\n delay: Delay\n}\n\n/**\n * @public\n * Provides context for a group of tooltip elements that should share a delay\n * which temporarily becomes 1 ms after the first floating element of the group opens.\n */\nexport function TooltipDelayGroupProvider(\n props: TooltipDelayGroupProviderProps,\n): React.JSX.Element {\n const {children, delay} = props\n const [isGroupActive, setIsGroupActive] = useDelayedState(false)\n const [openTooltipId, setOpenTooltipId] = useDelayedState<string | null>(null)\n\n const openDelay = typeof delay === 'number' ? delay : delay?.open || 0\n const closeDelay = typeof delay === 'number' ? delay : delay?.close || 0\n\n const value: TooltipDelayGroupContextValue = useMemo(\n () => ({\n setIsGroupActive: setIsGroupActive,\n openTooltipId: openTooltipId,\n setOpenTooltipId: setOpenTooltipId,\n // When the group is active, we want the next tooltip to open immediately.\n openDelay: isGroupActive ? 1 : openDelay,\n closeDelay: closeDelay,\n }),\n [closeDelay, isGroupActive, openDelay, openTooltipId, setIsGroupActive, setOpenTooltipId],\n )\n\n return (\n <TooltipDelayGroupContext.Provider value={value}>{children}</TooltipDelayGroupContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAKA,SAAgB,gBACd,cAC6D;eACvD,CAAC,OAAO,YAAY,SAAS,YAAY,GACzC,gBAAgB,OAAmC,KAAA,CAAS,GAEhCA;qDAAC,MAAA,WAA8B,UAAmB;EAClF,IAAM,eAAe;GACnB,SAAS,SAAS;EACpB;EAQA,IALA,AAEE,cAAc,aADd,aAAa,cAAc,OAAO,GACV,KAAA,IAGtB,CAAC,OAAO,OAAO,OAAO;EAC1B,cAAc,UAAU,WAAW,QAAQ,KAAK;CAClD;CAbA,IAAM,gBAAgBC,IAeZC,IAMPC;CANH,oDAAU,iBACK;EACX,AAAI,cAAc,WAChB,aAAa,cAAc,OAAO;CAEtC,GACC,KAAA,CAAC,mDANJ,UAAUD,IAMPC,EAAE;CAEEC,IAAAA;CAAP,OAAQ,EAAA,OAAA,qBAAD,KAAA,CAAC,OAAO,aAAa,GAApB,EAAA,KAAA,mBAADA;AACT;AC1BA,MAAa,8BAA8D;CACzE6F,KAAO;EAAC;EAAW;EAAa;EAAU;EAAQ;CAAO;CACzD,aAAa;EAAC;EAAO;EAAW;EAAgB;EAAc;CAAa;CAC3E,WAAW;EAAC;EAAO;EAAa;EAAc;EAAY;CAAW;CACrEC,QAAU;EAAC;EA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AW,GAA1B,EAAA,KAAA,eAAe,EAAA,KAAA,qCAXnB,UAAUD,IAWPC,EAA4B;AACjC;;;;;;ACtfA,SAAgB,0BACd,OACmB;eACb,EAAC,UAAU,UAAS,OACpB,CAAC,eAAe,oBAAoB,gBAAgB,EAAK,GACzD,CAAC,eAAe,oBAAoB,gBAA+B,IAAI,GAEvE,YAAY,OAAO,SAAU,WAAW,QAAQ,OAAO,QAAQ,GAC/D,aAAa,OAAO,SAAU,WAAW,QAAQ,OAAO,SAAS,GAQxD,KAAA,gBAAgB,IAAI,WAL1BG;CAMO,AAAA,EAAA,OAAA,cAAA,EAAA,OAJG,iBAAA,EAAA,OADG,oBAAA,EAAA,OAEA,oBAAA,EAAA,OAEPC,MALN,KAAA;EACa;EACH;EACG;EAElB,WAAWA;EACC;CACd,GADc,EAAA,KAAA,YAJG,EAAA,KAAA,eADG,EAAA,KAAA,kBAEA,EAAA,KAAA,kBAEPA,EAAAA,KAAAA;CANf,IAAM,QAAuCC,IAa3CC;CADF,OACoD,EAAA,OAAA,YAAA,EAAA,OAAR,SAA1C,KAAA,oBAACC,yBAAAA,UAAD;EAA0C;EAAQ;CAA4C,CAAA,GAA5C,EAAA,KAAA,UAAR,EAAA,KAAA,+BAA1CD;AAEJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "4.3.1",
3
+ "version": "4.3.3",
4
4
  "keywords": [
5
5
  "components",
6
6
  "design-system",
@@ -54,14 +54,14 @@
54
54
  "@vanilla-extract/dynamic": "^2.1.5",
55
55
  "clsx": "^2.1.1",
56
56
  "csstype": "^3.2.3",
57
- "motion": "^13.5.1",
57
+ "motion": "^14.0.0",
58
58
  "react-is": "^19.3.0",
59
59
  "react-refractor": "^4.0.0",
60
60
  "use-effect-event": "^2.0.4"
61
61
  },
62
62
  "devDependencies": {
63
- "@sanity/tsdown-config": "^0.28.4",
64
- "@sanity/vanilla-extract-vite-plugin": "^0.2.22",
63
+ "@sanity/tsdown-config": "^0.28.5",
64
+ "@sanity/vanilla-extract-vite-plugin": "^0.2.23",
65
65
  "@testing-library/dom": "^10.4.2",
66
66
  "@testing-library/jest-dom": "^7.0.1",
67
67
  "@testing-library/react": "^16.3.3",
@@ -71,6 +71,7 @@
71
71
  "@types/react-dom": "^19.3.0",
72
72
  "@types/react-is": "^19.3.0",
73
73
  "@vanilla-extract/css": "^1.21.2",
74
+ "@vitejs/plugin-react": "^6.1.2",
74
75
  "@vitest/coverage-v8": "^5.0.3",
75
76
  "jsdom": "^30.1.2",
76
77
  "oxc-transform-react": "^0.153.0",