@cypress-design/react-tooltip 0.10.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.mjs CHANGED
@@ -7057,7 +7057,7 @@ function requireReactDom_development () {
7057
7057
  return a !== 0 && a < b ? a : b;
7058
7058
  }
7059
7059
  function lowerEventPriority(a, b) {
7060
- return a === 0 || a > b ? a : b;
7060
+ return a > b ? a : b;
7061
7061
  }
7062
7062
  function isHigherEventPriority(a, b) {
7063
7063
  return a !== 0 && a < b;
@@ -10178,7 +10178,7 @@ function requireReactDom_development () {
10178
10178
 
10179
10179
  var isCapturePhaseListener = false;
10180
10180
  var listenerSet = getEventListenerSet(targetElement);
10181
- var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener);
10181
+ var listenerSetKey = getListenerSetKey(domEventName);
10182
10182
 
10183
10183
  if (!listenerSet.has(listenerSetKey)) {
10184
10184
  addTrappedEventListener(targetElement, domEventName, IS_NON_DELEGATED, isCapturePhaseListener);
@@ -10575,7 +10575,7 @@ function requireReactDom_development () {
10575
10575
  }
10576
10576
  }
10577
10577
  function getListenerSetKey(domEventName, capture) {
10578
- return domEventName + "__" + (capture ? 'capture' : 'bubble');
10578
+ return domEventName + "__" + ('bubble');
10579
10579
  }
10580
10580
 
10581
10581
  var didWarnInvalidHydration = false;
@@ -31164,7 +31164,7 @@ function isMouseLikePointerType(pointerType, strict) {
31164
31164
  // On some Linux machines with Chromium, mouse inputs return a `pointerType`
31165
31165
  // of "pen": https://github.com/floating-ui/floating-ui/issues/2015
31166
31166
  const values = ['mouse', 'pen'];
31167
- if (!strict) {
31167
+ {
31168
31168
  values.push('', undefined);
31169
31169
  }
31170
31170
  return values.includes(pointerType);
@@ -31545,7 +31545,7 @@ async function detectOverflow(state, options) {
31545
31545
  * appears centered to the reference element.
31546
31546
  * @see https://floating-ui.com/docs/arrow
31547
31547
  */
31548
- const arrow$2 = options => ({
31548
+ const arrow$3 = options => ({
31549
31549
  name: 'arrow',
31550
31550
  options,
31551
31551
  async fn(state) {
@@ -31628,7 +31628,7 @@ const arrow$2 = options => ({
31628
31628
  * clipping boundary. Alternative to `autoPlacement`.
31629
31629
  * @see https://floating-ui.com/docs/flip
31630
31630
  */
31631
- const flip$1 = function (options) {
31631
+ const flip$2 = function (options) {
31632
31632
  if (options === void 0) {
31633
31633
  options = {};
31634
31634
  }
@@ -31786,7 +31786,7 @@ async function convertValueToCoords(state, options) {
31786
31786
  * object may be passed.
31787
31787
  * @see https://floating-ui.com/docs/offset
31788
31788
  */
31789
- const offset = function (options) {
31789
+ const offset$2 = function (options) {
31790
31790
  if (options === void 0) {
31791
31791
  options = 0;
31792
31792
  }
@@ -31825,7 +31825,7 @@ const offset = function (options) {
31825
31825
  * keep it in view when it will overflow the clipping boundary.
31826
31826
  * @see https://floating-ui.com/docs/shift
31827
31827
  */
31828
- const shift$1 = function (options) {
31828
+ const shift$2 = function (options) {
31829
31829
  if (options === void 0) {
31830
31830
  options = {};
31831
31831
  }
@@ -31995,8 +31995,9 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
31995
31995
  if (domElement) {
31996
31996
  const win = getWindow(domElement);
31997
31997
  const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
31998
- let currentIFrame = win.frameElement;
31999
- while (currentIFrame && offsetParent && offsetWin !== win) {
31998
+ let currentWin = win;
31999
+ let currentIFrame = currentWin.frameElement;
32000
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
32000
32001
  const iframeScale = getScale(currentIFrame);
32001
32002
  const iframeRect = currentIFrame.getBoundingClientRect();
32002
32003
  const css = getComputedStyle(currentIFrame);
@@ -32008,7 +32009,8 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
32008
32009
  height *= iframeScale.y;
32009
32010
  x += left;
32010
32011
  y += top;
32011
- currentIFrame = getWindow(currentIFrame).frameElement;
32012
+ currentWin = getWindow(currentIFrame);
32013
+ currentIFrame = currentWin.frameElement;
32012
32014
  }
32013
32015
  }
32014
32016
  return rectToClientRect({
@@ -32020,27 +32022,14 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
32020
32022
  }
32021
32023
 
32022
32024
  const topLayerSelectors = [':popover-open', ':modal'];
32023
- function topLayer(floating) {
32024
- let isTopLayer = false;
32025
- let x = 0;
32026
- let y = 0;
32027
- function setIsTopLayer(selector) {
32025
+ function isTopLayer(element) {
32026
+ return topLayerSelectors.some(selector => {
32028
32027
  try {
32029
- isTopLayer = isTopLayer || floating.matches(selector);
32030
- } catch (e) {}
32031
- }
32032
- topLayerSelectors.forEach(selector => {
32033
- setIsTopLayer(selector);
32034
- });
32035
- if (isTopLayer) {
32036
- const containingBlock = getContainingBlock(floating);
32037
- if (containingBlock) {
32038
- const rect = containingBlock.getBoundingClientRect();
32039
- x = rect.x;
32040
- y = rect.y;
32028
+ return element.matches(selector);
32029
+ } catch (e) {
32030
+ return false;
32041
32031
  }
32042
- }
32043
- return [isTopLayer, x, y];
32032
+ });
32044
32033
  }
32045
32034
 
32046
32035
  function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
@@ -32050,9 +32039,10 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
32050
32039
  offsetParent,
32051
32040
  strategy
32052
32041
  } = _ref;
32042
+ const isFixed = strategy === 'fixed';
32053
32043
  const documentElement = getDocumentElement(offsetParent);
32054
- const [isTopLayer] = elements ? topLayer(elements.floating) : [false];
32055
- if (offsetParent === documentElement || isTopLayer) {
32044
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
32045
+ if (offsetParent === documentElement || topLayer && isFixed) {
32056
32046
  return rect;
32057
32047
  }
32058
32048
  let scroll = {
@@ -32062,7 +32052,7 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
32062
32052
  let scale = createCoords(1);
32063
32053
  const offsets = createCoords(0);
32064
32054
  const isOffsetParentAnElement = isHTMLElement(offsetParent);
32065
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
32055
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
32066
32056
  if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
32067
32057
  scroll = getNodeScroll(offsetParent);
32068
32058
  }
@@ -32223,7 +32213,7 @@ function getClippingRect(_ref) {
32223
32213
  rootBoundary,
32224
32214
  strategy
32225
32215
  } = _ref;
32226
- const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
32216
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
32227
32217
  const clippingAncestors = [...elementClippingAncestors, rootBoundary];
32228
32218
  const firstClippingAncestor = clippingAncestors[0];
32229
32219
  const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
@@ -32253,7 +32243,7 @@ function getDimensions(element) {
32253
32243
  };
32254
32244
  }
32255
32245
 
32256
- function getRectRelativeToOffsetParent(element, offsetParent, strategy, floating) {
32246
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
32257
32247
  const isOffsetParentAnElement = isHTMLElement(offsetParent);
32258
32248
  const documentElement = getDocumentElement(offsetParent);
32259
32249
  const isFixed = strategy === 'fixed';
@@ -32275,17 +32265,8 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy, floating
32275
32265
  offsets.x = getWindowScrollBarX(documentElement);
32276
32266
  }
32277
32267
  }
32278
- let x = rect.left + scroll.scrollLeft - offsets.x;
32279
- let y = rect.top + scroll.scrollTop - offsets.y;
32280
- const [isTopLayer, topLayerX, topLayerY] = topLayer(floating);
32281
- if (isTopLayer) {
32282
- x += topLayerX;
32283
- y += topLayerY;
32284
- if (isOffsetParentAnElement) {
32285
- x += offsetParent.clientLeft;
32286
- y += offsetParent.clientTop;
32287
- }
32288
- }
32268
+ const x = rect.left + scroll.scrollLeft - offsets.x;
32269
+ const y = rect.top + scroll.scrollTop - offsets.y;
32289
32270
  return {
32290
32271
  x,
32291
32272
  y,
@@ -32294,6 +32275,10 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy, floating
32294
32275
  };
32295
32276
  }
32296
32277
 
32278
+ function isStaticPositioned(element) {
32279
+ return getComputedStyle(element).position === 'static';
32280
+ }
32281
+
32297
32282
  function getTrueOffsetParent(element, polyfill) {
32298
32283
  if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
32299
32284
  return null;
@@ -32307,29 +32292,41 @@ function getTrueOffsetParent(element, polyfill) {
32307
32292
  // Gets the closest ancestor positioned element. Handles some edge cases,
32308
32293
  // such as table ancestors and cross browser bugs.
32309
32294
  function getOffsetParent(element, polyfill) {
32310
- const window = getWindow(element);
32295
+ const win = getWindow(element);
32296
+ if (isTopLayer(element)) {
32297
+ return win;
32298
+ }
32311
32299
  if (!isHTMLElement(element)) {
32312
- return window;
32300
+ let svgOffsetParent = getParentNode(element);
32301
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
32302
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
32303
+ return svgOffsetParent;
32304
+ }
32305
+ svgOffsetParent = getParentNode(svgOffsetParent);
32306
+ }
32307
+ return win;
32313
32308
  }
32314
32309
  let offsetParent = getTrueOffsetParent(element, polyfill);
32315
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
32310
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
32316
32311
  offsetParent = getTrueOffsetParent(offsetParent, polyfill);
32317
32312
  }
32318
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
32319
- return window;
32313
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
32314
+ return win;
32320
32315
  }
32321
- return offsetParent || getContainingBlock(element) || window;
32316
+ return offsetParent || getContainingBlock(element) || win;
32322
32317
  }
32323
32318
 
32324
32319
  const getElementRects = async function (data) {
32325
32320
  const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
32326
32321
  const getDimensionsFn = this.getDimensions;
32322
+ const floatingDimensions = await getDimensionsFn(data.floating);
32327
32323
  return {
32328
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy, data.floating),
32324
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
32329
32325
  floating: {
32330
32326
  x: 0,
32331
32327
  y: 0,
32332
- ...(await getDimensionsFn(data.floating))
32328
+ width: floatingDimensions.width,
32329
+ height: floatingDimensions.height
32333
32330
  }
32334
32331
  };
32335
32332
  };
@@ -32399,9 +32396,11 @@ function observeMove(element, onMove) {
32399
32396
  return refresh();
32400
32397
  }
32401
32398
  if (!ratio) {
32399
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
32400
+ // to prevent an infinite loop of updates.
32402
32401
  timeoutId = setTimeout(() => {
32403
32402
  refresh(false, 1e-7);
32404
- }, 100);
32403
+ }, 1000);
32405
32404
  } else {
32406
32405
  refresh(false, ratio);
32407
32406
  }
@@ -32505,12 +32504,21 @@ function autoUpdate(reference, floating, update, options) {
32505
32504
  };
32506
32505
  }
32507
32506
 
32507
+ /**
32508
+ * Modifies the placement by translating the floating element along the
32509
+ * specified axes.
32510
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
32511
+ * object may be passed.
32512
+ * @see https://floating-ui.com/docs/offset
32513
+ */
32514
+ const offset$1 = offset$2;
32515
+
32508
32516
  /**
32509
32517
  * Optimizes the visibility of the floating element by shifting it in order to
32510
32518
  * keep it in view when it will overflow the clipping boundary.
32511
32519
  * @see https://floating-ui.com/docs/shift
32512
32520
  */
32513
- const shift = shift$1;
32521
+ const shift$1 = shift$2;
32514
32522
 
32515
32523
  /**
32516
32524
  * Optimizes the visibility of the floating element by flipping the `placement`
@@ -32518,14 +32526,14 @@ const shift = shift$1;
32518
32526
  * clipping boundary. Alternative to `autoPlacement`.
32519
32527
  * @see https://floating-ui.com/docs/flip
32520
32528
  */
32521
- const flip = flip$1;
32529
+ const flip$1 = flip$2;
32522
32530
 
32523
32531
  /**
32524
32532
  * Provides data to position an inner element of the floating element so that it
32525
32533
  * appears centered to the reference element.
32526
32534
  * @see https://floating-ui.com/docs/arrow
32527
32535
  */
32528
- const arrow$1 = arrow$2;
32536
+ const arrow$2 = arrow$3;
32529
32537
 
32530
32538
  /**
32531
32539
  * Computes the `x` and `y` coordinates that will place the floating element
@@ -32550,44 +32558,6 @@ const computePosition = (reference, floating, options) => {
32550
32558
  });
32551
32559
  };
32552
32560
 
32553
- /**
32554
- * Provides data to position an inner element of the floating element so that it
32555
- * appears centered to the reference element.
32556
- * This wraps the core `arrow` middleware to allow React refs as the element.
32557
- * @see https://floating-ui.com/docs/arrow
32558
- */
32559
- const arrow = options => {
32560
- function isRef(value) {
32561
- return {}.hasOwnProperty.call(value, 'current');
32562
- }
32563
- return {
32564
- name: 'arrow',
32565
- options,
32566
- fn(state) {
32567
- const {
32568
- element,
32569
- padding
32570
- } = typeof options === 'function' ? options(state) : options;
32571
- if (element && isRef(element)) {
32572
- if (element.current != null) {
32573
- return arrow$1({
32574
- element: element.current,
32575
- padding
32576
- }).fn(state);
32577
- }
32578
- return {};
32579
- }
32580
- if (element) {
32581
- return arrow$1({
32582
- element,
32583
- padding
32584
- }).fn(state);
32585
- }
32586
- return {};
32587
- }
32588
- };
32589
- };
32590
-
32591
32561
  var index$1 = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
32592
32562
 
32593
32563
  // Fork of `fast-deep-equal` that only does the comparisons we need and compares
@@ -32637,8 +32607,6 @@ function deepEqual(a, b) {
32637
32607
  }
32638
32608
  return true;
32639
32609
  }
32640
-
32641
- // biome-ignore lint/suspicious/noSelfCompare: in source
32642
32610
  return a !== a && b !== b;
32643
32611
  }
32644
32612
 
@@ -32759,8 +32727,6 @@ function useFloating$1(options) {
32759
32727
  isMountedRef.current = false;
32760
32728
  };
32761
32729
  }, []);
32762
-
32763
- // biome-ignore lint/correctness/useExhaustiveDependencies: `hasWhileElementsMounted` is intentionally included.
32764
32730
  index$1(() => {
32765
32731
  if (referenceEl) referenceRef.current = referenceEl;
32766
32732
  if (floatingEl) floatingRef.current = floatingEl;
@@ -32816,8 +32782,94 @@ function useFloating$1(options) {
32816
32782
  }), [data, update, refs, elements, floatingStyles]);
32817
32783
  }
32818
32784
 
32819
- // `toString()` prevents bundlers from trying to `import { useInsertionEffect } from 'react'`
32820
- const useInsertionEffect = React[/*#__PURE__*/'useInsertionEffect'.toString()];
32785
+ /**
32786
+ * Provides data to position an inner element of the floating element so that it
32787
+ * appears centered to the reference element.
32788
+ * This wraps the core `arrow` middleware to allow React refs as the element.
32789
+ * @see https://floating-ui.com/docs/arrow
32790
+ */
32791
+ const arrow$1 = options => {
32792
+ function isRef(value) {
32793
+ return {}.hasOwnProperty.call(value, 'current');
32794
+ }
32795
+ return {
32796
+ name: 'arrow',
32797
+ options,
32798
+ fn(state) {
32799
+ const {
32800
+ element,
32801
+ padding
32802
+ } = typeof options === 'function' ? options(state) : options;
32803
+ if (element && isRef(element)) {
32804
+ if (element.current != null) {
32805
+ return arrow$2({
32806
+ element: element.current,
32807
+ padding
32808
+ }).fn(state);
32809
+ }
32810
+ return {};
32811
+ }
32812
+ if (element) {
32813
+ return arrow$2({
32814
+ element,
32815
+ padding
32816
+ }).fn(state);
32817
+ }
32818
+ return {};
32819
+ }
32820
+ };
32821
+ };
32822
+
32823
+ /**
32824
+ * Modifies the placement by translating the floating element along the
32825
+ * specified axes.
32826
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
32827
+ * object may be passed.
32828
+ * @see https://floating-ui.com/docs/offset
32829
+ */
32830
+ const offset = (options, deps) => ({
32831
+ ...offset$1(options),
32832
+ options: [options, deps]
32833
+ });
32834
+
32835
+ /**
32836
+ * Optimizes the visibility of the floating element by shifting it in order to
32837
+ * keep it in view when it will overflow the clipping boundary.
32838
+ * @see https://floating-ui.com/docs/shift
32839
+ */
32840
+ const shift = (options, deps) => ({
32841
+ ...shift$1(options),
32842
+ options: [options, deps]
32843
+ });
32844
+
32845
+ /**
32846
+ * Optimizes the visibility of the floating element by flipping the `placement`
32847
+ * in order to keep it in view when the preferred placement(s) will overflow the
32848
+ * clipping boundary. Alternative to `autoPlacement`.
32849
+ * @see https://floating-ui.com/docs/flip
32850
+ */
32851
+ const flip = (options, deps) => ({
32852
+ ...flip$1(options),
32853
+ options: [options, deps]
32854
+ });
32855
+
32856
+ /**
32857
+ * Provides data to position an inner element of the floating element so that it
32858
+ * appears centered to the reference element.
32859
+ * This wraps the core `arrow` middleware to allow React refs as the element.
32860
+ * @see https://floating-ui.com/docs/arrow
32861
+ */
32862
+ const arrow = (options, deps) => ({
32863
+ ...arrow$1(options),
32864
+ options: [options, deps]
32865
+ });
32866
+
32867
+ // https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
32868
+ const SafeReact = {
32869
+ ...React
32870
+ };
32871
+
32872
+ const useInsertionEffect = SafeReact.useInsertionEffect;
32821
32873
  const useSafeInsertionEffect = useInsertionEffect || (fn => fn());
32822
32874
  function useEffectEvent(callback) {
32823
32875
  const ref = React.useRef(() => {
@@ -32840,26 +32892,23 @@ var index = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
32840
32892
 
32841
32893
  let serverHandoffComplete = false;
32842
32894
  let count = 0;
32843
- const genId = () => "floating-ui-" + count++;
32895
+ const genId = () => // Ensure the id is unique with multiple independent versions of Floating UI
32896
+ // on <React 18
32897
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++;
32844
32898
  function useFloatingId() {
32845
32899
  const [id, setId] = React.useState(() => serverHandoffComplete ? genId() : undefined);
32846
-
32847
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
32848
32900
  index(() => {
32849
32901
  if (id == null) {
32850
32902
  setId(genId());
32851
32903
  }
32904
+ // eslint-disable-next-line react-hooks/exhaustive-deps
32852
32905
  }, []);
32853
32906
  React.useEffect(() => {
32854
- if (!serverHandoffComplete) {
32855
- serverHandoffComplete = true;
32856
- }
32907
+ serverHandoffComplete = true;
32857
32908
  }, []);
32858
32909
  return id;
32859
32910
  }
32860
-
32861
- // `toString()` prevents bundlers from trying to `import { useId } from 'react'`
32862
- const useReactId = React[/*#__PURE__*/'useId'.toString()];
32911
+ const useReactId = SafeReact.useId;
32863
32912
 
32864
32913
  /**
32865
32914
  * Uses React 18's built-in `useId()` when available, or falls back to a
@@ -32869,6 +32918,23 @@ const useReactId = React[/*#__PURE__*/'useId'.toString()];
32869
32918
  */
32870
32919
  const useId = useReactId || useFloatingId;
32871
32920
 
32921
+ let devMessageSet;
32922
+ if (process.env.NODE_ENV !== "production") {
32923
+ devMessageSet = /*#__PURE__*/new Set();
32924
+ }
32925
+ function error() {
32926
+ var _devMessageSet3;
32927
+ for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
32928
+ messages[_key2] = arguments[_key2];
32929
+ }
32930
+ const message = "Floating UI: " + messages.join(' ');
32931
+ if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
32932
+ var _devMessageSet4;
32933
+ (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
32934
+ console.error(message);
32935
+ }
32936
+ }
32937
+
32872
32938
  function createPubSub() {
32873
32939
  const map = new Map();
32874
32940
  return {
@@ -32942,8 +33008,7 @@ function useHover(context, props) {
32942
33008
  elements: {
32943
33009
  domReference,
32944
33010
  floating
32945
- },
32946
- refs
33011
+ }
32947
33012
  } = context;
32948
33013
  const {
32949
33014
  enabled = true,
@@ -32958,9 +33023,9 @@ function useHover(context, props) {
32958
33023
  const handleCloseRef = useLatestRef(handleClose);
32959
33024
  const delayRef = useLatestRef(delay);
32960
33025
  const pointerTypeRef = React.useRef();
32961
- const timeoutRef = React.useRef();
33026
+ const timeoutRef = React.useRef(-1);
32962
33027
  const handlerRef = React.useRef();
32963
- const restTimeoutRef = React.useRef();
33028
+ const restTimeoutRef = React.useRef(-1);
32964
33029
  const blockMouseMoveRef = React.useRef(true);
32965
33030
  const performedPointerEventsMutationRef = React.useRef(false);
32966
33031
  const unbindMouseMoveRef = React.useRef(() => {});
@@ -33016,24 +33081,24 @@ function useHover(context, props) {
33016
33081
  const closeDelay = getDelay(delayRef.current, 'close', pointerTypeRef.current);
33017
33082
  if (closeDelay && !handlerRef.current) {
33018
33083
  clearTimeout(timeoutRef.current);
33019
- timeoutRef.current = setTimeout(() => onOpenChange(false, event, reason), closeDelay);
33084
+ timeoutRef.current = window.setTimeout(() => onOpenChange(false, event, reason), closeDelay);
33020
33085
  } else if (runElseBranch) {
33021
33086
  clearTimeout(timeoutRef.current);
33022
33087
  onOpenChange(false, event, reason);
33023
33088
  }
33024
33089
  }, [delayRef, onOpenChange]);
33025
- const cleanupMouseMoveHandler = React.useCallback(() => {
33090
+ const cleanupMouseMoveHandler = useEffectEvent(() => {
33026
33091
  unbindMouseMoveRef.current();
33027
33092
  handlerRef.current = undefined;
33028
- }, []);
33029
- const clearPointerEvents = React.useCallback(() => {
33093
+ });
33094
+ const clearPointerEvents = useEffectEvent(() => {
33030
33095
  if (performedPointerEventsMutationRef.current) {
33031
- const body = getDocument(refs.floating.current).body;
33096
+ const body = getDocument(floating).body;
33032
33097
  body.style.pointerEvents = '';
33033
33098
  body.removeAttribute(safePolygonIdentifier);
33034
33099
  performedPointerEventsMutationRef.current = false;
33035
33100
  }
33036
- }, [refs]);
33101
+ });
33037
33102
 
33038
33103
  // Registering the mouse events on the reference directly to bypass React's
33039
33104
  // delegation system. If the cursor was on a disabled element and then entered
@@ -33048,12 +33113,12 @@ function useHover(context, props) {
33048
33113
  function onMouseEnter(event) {
33049
33114
  clearTimeout(timeoutRef.current);
33050
33115
  blockMouseMoveRef.current = false;
33051
- if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current) || restMs > 0 && getDelay(delayRef.current, 'open') === 0) {
33116
+ if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current) || restMs > 0 && !getDelay(delayRef.current, 'open')) {
33052
33117
  return;
33053
33118
  }
33054
33119
  const openDelay = getDelay(delayRef.current, 'open', pointerTypeRef.current);
33055
33120
  if (openDelay) {
33056
- timeoutRef.current = setTimeout(() => {
33121
+ timeoutRef.current = window.setTimeout(() => {
33057
33122
  onOpenChange(true, event, 'hover');
33058
33123
  }, openDelay);
33059
33124
  } else {
@@ -33061,19 +33126,17 @@ function useHover(context, props) {
33061
33126
  }
33062
33127
  }
33063
33128
  function onMouseLeave(event) {
33064
- if (isClickLikeOpenEvent()) {
33065
- return;
33066
- }
33129
+ if (isClickLikeOpenEvent()) return;
33067
33130
  unbindMouseMoveRef.current();
33068
33131
  const doc = getDocument(floating);
33069
33132
  clearTimeout(restTimeoutRef.current);
33070
- if (handleCloseRef.current) {
33133
+ if (handleCloseRef.current && dataRef.current.floatingContext) {
33071
33134
  // Prevent clearing `onScrollMouseLeave` timeout.
33072
33135
  if (!open) {
33073
33136
  clearTimeout(timeoutRef.current);
33074
33137
  }
33075
33138
  handlerRef.current = handleCloseRef.current({
33076
- ...context,
33139
+ ...dataRef.current.floatingContext,
33077
33140
  tree,
33078
33141
  x: event.clientX,
33079
33142
  y: event.clientY,
@@ -33104,11 +33167,10 @@ function useHover(context, props) {
33104
33167
  // did not move.
33105
33168
  // https://github.com/floating-ui/floating-ui/discussions/1692
33106
33169
  function onScrollMouseLeave(event) {
33107
- if (isClickLikeOpenEvent()) {
33108
- return;
33109
- }
33170
+ if (isClickLikeOpenEvent()) return;
33171
+ if (!dataRef.current.floatingContext) return;
33110
33172
  handleCloseRef.current == null || handleCloseRef.current({
33111
- ...context,
33173
+ ...dataRef.current.floatingContext,
33112
33174
  tree,
33113
33175
  x: event.clientX,
33114
33176
  y: event.clientY,
@@ -33175,8 +33237,6 @@ function useHover(context, props) {
33175
33237
  clearPointerEvents();
33176
33238
  }
33177
33239
  }, [open, cleanupMouseMoveHandler, clearPointerEvents]);
33178
-
33179
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
33180
33240
  React.useEffect(() => {
33181
33241
  return () => {
33182
33242
  cleanupMouseMoveHandler();
@@ -33197,15 +33257,23 @@ function useHover(context, props) {
33197
33257
  onPointerDown: setPointerRef,
33198
33258
  onPointerEnter: setPointerRef,
33199
33259
  onMouseMove(event) {
33260
+ function handleMouseMove() {
33261
+ if (!blockMouseMoveRef.current) {
33262
+ onOpenChange(true, event.nativeEvent, 'hover');
33263
+ }
33264
+ }
33265
+ if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current)) {
33266
+ return;
33267
+ }
33200
33268
  if (open || restMs === 0) {
33201
33269
  return;
33202
33270
  }
33203
33271
  clearTimeout(restTimeoutRef.current);
33204
- restTimeoutRef.current = setTimeout(() => {
33205
- if (!blockMouseMoveRef.current) {
33206
- onOpenChange(true, event.nativeEvent, 'hover');
33207
- }
33208
- }, restMs);
33272
+ if (pointerTypeRef.current === 'touch') {
33273
+ handleMouseMove();
33274
+ } else {
33275
+ restTimeoutRef.current = window.setTimeout(handleMouseMove, restMs);
33276
+ }
33209
33277
  }
33210
33278
  },
33211
33279
  floating: {
@@ -33217,7 +33285,7 @@ function useHover(context, props) {
33217
33285
  }
33218
33286
  }
33219
33287
  };
33220
- }, [enabled, restMs, open, onOpenChange, closeWithDelay]);
33288
+ }, [enabled, mouseOnly, open, restMs, onOpenChange, closeWithDelay]);
33221
33289
  }
33222
33290
 
33223
33291
  function getChildren(nodes, id) {
@@ -33268,7 +33336,6 @@ function useDismiss(context, props) {
33268
33336
  const {
33269
33337
  open,
33270
33338
  onOpenChange,
33271
- nodeId,
33272
33339
  elements: {
33273
33340
  reference,
33274
33341
  domReference,
@@ -33301,9 +33368,11 @@ function useDismiss(context, props) {
33301
33368
  outsidePress: outsidePressCapture
33302
33369
  } = normalizeProp(capture);
33303
33370
  const closeOnEscapeKeyDown = useEffectEvent(event => {
33371
+ var _dataRef$current$floa;
33304
33372
  if (!open || !enabled || !escapeKey || event.key !== 'Escape') {
33305
33373
  return;
33306
33374
  }
33375
+ const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
33307
33376
  const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
33308
33377
  if (!escapeKeyBubbles) {
33309
33378
  event.stopPropagation();
@@ -33333,6 +33402,7 @@ function useDismiss(context, props) {
33333
33402
  (_getTarget2 = getTarget(event)) == null || _getTarget2.addEventListener('keydown', callback);
33334
33403
  });
33335
33404
  const closeOnPressOutside = useEffectEvent(event => {
33405
+ var _dataRef$current$floa2;
33336
33406
  // Given developers can stop the propagation of the synthetic event,
33337
33407
  // we can only be confident with a positive value.
33338
33408
  const insideReactTree = insideReactTreeRef.current;
@@ -33398,6 +33468,7 @@ function useDismiss(context, props) {
33398
33468
  return;
33399
33469
  }
33400
33470
  }
33471
+ const nodeId = (_dataRef$current$floa2 = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa2.nodeId;
33401
33472
  const targetIsInsideChildren = tree && getChildren(tree.nodesRef.current, nodeId).some(node => {
33402
33473
  var _node$context;
33403
33474
  return isEventTargetWithin(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating);
@@ -33473,8 +33544,6 @@ function useDismiss(context, props) {
33473
33544
  });
33474
33545
  };
33475
33546
  }, [dataRef, floating, domReference, reference, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture]);
33476
-
33477
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
33478
33547
  React.useEffect(() => {
33479
33548
  insideReactTreeRef.current = false;
33480
33549
  }, [outsidePress, outsidePressEvent]);
@@ -33507,9 +33576,50 @@ function useDismiss(context, props) {
33507
33576
  }, [enabled, referencePress, outsidePressEvent, referencePressEvent, onOpenChange, closeOnEscapeKeyDown]);
33508
33577
  }
33509
33578
 
33510
- let devMessageSet;
33511
- if (process.env.NODE_ENV !== "production") {
33512
- devMessageSet = /*#__PURE__*/new Set();
33579
+ function useFloatingRootContext(options) {
33580
+ const {
33581
+ open = false,
33582
+ onOpenChange: onOpenChangeProp,
33583
+ elements: elementsProp
33584
+ } = options;
33585
+ const floatingId = useId();
33586
+ const dataRef = React.useRef({});
33587
+ const [events] = React.useState(() => createPubSub());
33588
+ const nested = useFloatingParentNodeId() != null;
33589
+ if (process.env.NODE_ENV !== "production") {
33590
+ const optionDomReference = elementsProp.reference;
33591
+ if (optionDomReference && !isElement(optionDomReference)) {
33592
+ error('Cannot pass a virtual element to the `elements.reference` option,', 'as it must be a real DOM element. Use `refs.setPositionReference()`', 'instead.');
33593
+ }
33594
+ }
33595
+ const [positionReference, setPositionReference] = React.useState(elementsProp.reference);
33596
+ const onOpenChange = useEffectEvent((open, event, reason) => {
33597
+ dataRef.current.openEvent = open ? event : undefined;
33598
+ events.emit('openchange', {
33599
+ open,
33600
+ event,
33601
+ reason,
33602
+ nested
33603
+ });
33604
+ onOpenChangeProp == null || onOpenChangeProp(open, event, reason);
33605
+ });
33606
+ const refs = React.useMemo(() => ({
33607
+ setPositionReference
33608
+ }), []);
33609
+ const elements = React.useMemo(() => ({
33610
+ reference: positionReference || elementsProp.reference || null,
33611
+ floating: elementsProp.floating || null,
33612
+ domReference: elementsProp.reference
33613
+ }), [positionReference, elementsProp.reference, elementsProp.floating]);
33614
+ return React.useMemo(() => ({
33615
+ dataRef,
33616
+ open,
33617
+ onOpenChange,
33618
+ elements,
33619
+ events,
33620
+ floatingId,
33621
+ refs
33622
+ }), [open, onOpenChange, elements, events, floatingId, refs]);
33513
33623
  }
33514
33624
 
33515
33625
  /**
@@ -33517,54 +33627,51 @@ if (process.env.NODE_ENV !== "production") {
33517
33627
  * @see https://floating-ui.com/docs/useFloating
33518
33628
  */
33519
33629
  function useFloating(options) {
33520
- var _options$elements2;
33521
33630
  if (options === void 0) {
33522
33631
  options = {};
33523
33632
  }
33524
33633
  const {
33525
- open = false,
33526
- onOpenChange: unstable_onOpenChange,
33527
33634
  nodeId
33528
33635
  } = options;
33529
- if (process.env.NODE_ENV !== "production") {
33530
- var _options$elements;
33531
- const err = 'Floating UI: Cannot pass a virtual element to the ' + '`elements.reference` option, as it must be a real DOM element. ' + 'Use `refs.setPositionReference` instead.';
33532
- if ((_options$elements = options.elements) != null && _options$elements.reference && !isElement(options.elements.reference)) {
33533
- var _devMessageSet;
33534
- if (!((_devMessageSet = devMessageSet) != null && _devMessageSet.has(err))) {
33535
- var _devMessageSet2;
33536
- (_devMessageSet2 = devMessageSet) == null || _devMessageSet2.add(err);
33537
- console.error(err);
33538
- }
33636
+ const internalRootContext = useFloatingRootContext({
33637
+ ...options,
33638
+ elements: {
33639
+ reference: null,
33640
+ floating: null,
33641
+ ...options.elements
33539
33642
  }
33540
- }
33643
+ });
33644
+ const rootContext = options.rootContext || internalRootContext;
33645
+ const computedElements = rootContext.elements;
33541
33646
  const [_domReference, setDomReference] = React.useState(null);
33542
- const domReference = ((_options$elements2 = options.elements) == null ? void 0 : _options$elements2.reference) || _domReference;
33543
- const position = useFloating$1(options);
33647
+ const [positionReference, _setPositionReference] = React.useState(null);
33648
+ const optionDomReference = computedElements == null ? void 0 : computedElements.reference;
33649
+ const domReference = optionDomReference || _domReference;
33650
+ const domReferenceRef = React.useRef(null);
33544
33651
  const tree = useFloatingTree();
33545
- const nested = useFloatingParentNodeId() != null;
33546
- const onOpenChange = useEffectEvent((open, event, reason) => {
33547
- if (open) {
33548
- dataRef.current.openEvent = event;
33652
+ index(() => {
33653
+ if (domReference) {
33654
+ domReferenceRef.current = domReference;
33655
+ }
33656
+ }, [domReference]);
33657
+ const position = useFloating$1({
33658
+ ...options,
33659
+ elements: {
33660
+ ...computedElements,
33661
+ ...(positionReference && {
33662
+ reference: positionReference
33663
+ })
33549
33664
  }
33550
- events.emit('openchange', {
33551
- open,
33552
- event,
33553
- reason,
33554
- nested
33555
- });
33556
- unstable_onOpenChange == null || unstable_onOpenChange(open, event, reason);
33557
33665
  });
33558
- const domReferenceRef = React.useRef(null);
33559
- const dataRef = React.useRef({});
33560
- const events = React.useState(() => createPubSub())[0];
33561
- const floatingId = useId();
33562
33666
  const setPositionReference = React.useCallback(node => {
33563
- const positionReference = isElement(node) ? {
33667
+ const computedPositionReference = isElement(node) ? {
33564
33668
  getBoundingClientRect: () => node.getBoundingClientRect(),
33565
33669
  contextElement: node
33566
33670
  } : node;
33567
- position.refs.setReference(positionReference);
33671
+ // Store the positionReference in state if the DOM reference is specified externally via the
33672
+ // `elements.reference` option. This ensures that it won't be overridden on future renders.
33673
+ _setPositionReference(computedPositionReference);
33674
+ position.refs.setReference(computedPositionReference);
33568
33675
  }, [position.refs]);
33569
33676
  const setReference = React.useCallback(node => {
33570
33677
  if (isElement(node) || node === null) {
@@ -33594,16 +33701,13 @@ function useFloating(options) {
33594
33701
  }), [position.elements, domReference]);
33595
33702
  const context = React.useMemo(() => ({
33596
33703
  ...position,
33704
+ ...rootContext,
33597
33705
  refs,
33598
33706
  elements,
33599
- dataRef,
33600
- nodeId,
33601
- floatingId,
33602
- events,
33603
- open,
33604
- onOpenChange
33605
- }), [position, nodeId, floatingId, events, open, onOpenChange, refs, elements]);
33707
+ nodeId
33708
+ }), [position, refs, elements, nodeId, rootContext]);
33606
33709
  index(() => {
33710
+ rootContext.dataRef.current.floatingContext = context;
33607
33711
  const node = tree == null ? void 0 : tree.nodesRef.current.find(node => node.id === nodeId);
33608
33712
  if (node) {
33609
33713
  node.context = context;
@@ -33630,7 +33734,7 @@ function useFocus(context, props) {
33630
33734
  open,
33631
33735
  onOpenChange,
33632
33736
  events,
33633
- refs,
33737
+ dataRef,
33634
33738
  elements: {
33635
33739
  domReference
33636
33740
  }
@@ -33730,6 +33834,7 @@ function useFocus(context, props) {
33730
33834
 
33731
33835
  // Wait for the window blur listener to fire.
33732
33836
  timeoutRef.current = window.setTimeout(() => {
33837
+ var _dataRef$current$floa;
33733
33838
  const activeEl = activeElement(domReference ? domReference.ownerDocument : document);
33734
33839
 
33735
33840
  // Focus left the page, keep it open.
@@ -33742,7 +33847,7 @@ function useFocus(context, props) {
33742
33847
  // as it will only point to the shadow host of the newly focused element
33743
33848
  // and not the element that actually has received focus if it is located
33744
33849
  // inside a shadow root.
33745
- if (contains(refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
33850
+ if (contains((_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
33746
33851
  return;
33747
33852
  }
33748
33853
  onOpenChange(false, event.nativeEvent, 'focus');
@@ -33750,7 +33855,7 @@ function useFocus(context, props) {
33750
33855
  }
33751
33856
  }
33752
33857
  };
33753
- }, [enabled, visibleOnly, domReference, refs, onOpenChange]);
33858
+ }, [enabled, visibleOnly, dataRef, domReference, onOpenChange]);
33754
33859
  }
33755
33860
 
33756
33861
  const ACTIVE_KEY = 'active';
@@ -33810,7 +33915,6 @@ function mergeProps(userProps, propsList, elementKey) {
33810
33915
  }, {})
33811
33916
  };
33812
33917
  }
33813
-
33814
33918
  /**
33815
33919
  * Merges an array of interaction hooks' props into prop getters, allowing
33816
33920
  * event handler functions to be composed together without overwriting one
@@ -33824,19 +33928,18 @@ function useInteractions(propsList) {
33824
33928
  // The dependencies are a dynamic array, so we can't use the linter's
33825
33929
  // suggestion to add it to the deps array.
33826
33930
  const deps = propsList;
33827
-
33828
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
33829
- const getReferenceProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'reference'), deps);
33830
-
33831
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
33832
- const getFloatingProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'floating'), deps);
33833
-
33834
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
33931
+ const getReferenceProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'reference'),
33932
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33933
+ deps);
33934
+ const getFloatingProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'floating'),
33935
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33936
+ deps);
33835
33937
  const getItemProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'item'),
33836
33938
  // Granularly check for `item` changes, because the `getItemProps` getter
33837
33939
  // should be as referentially stable as possible since it may be passed as
33838
33940
  // a prop to many components. All `item` key values must therefore be
33839
33941
  // memoized.
33942
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33840
33943
  propsList.map(key => key == null ? void 0 : key.item));
33841
33944
  return React.useMemo(() => ({
33842
33945
  getReferenceProps,
@@ -34188,7 +34291,7 @@ var Tooltip = function (_a) {
34188
34291
  fn: function (obj) { return obj; },
34189
34292
  }
34190
34293
  : flip(),
34191
- offset(interactive ? 0 : 16),
34294
+ offset(16),
34192
34295
  arrow({ element: arrowRef, padding: 24 }),
34193
34296
  shift({ padding: 16 }),
34194
34297
  ],
@@ -34257,8 +34360,8 @@ var Tooltip = function (_a) {
34257
34360
  ? 'drop-shadow(0 1px 1px rgba(225, 227, 237, .3))'
34258
34361
  : 'drop-shadow(0 1px 1px rgba(225, 227, 237, .8))'
34259
34362
  },
34260
- _b[arrowXRule] = "".concat(arrowX !== null && arrowX !== void 0 ? arrowX : (interactive ? 0 : -16), "px"),
34261
- _b[arrowYRule] = "".concat(arrowY ? arrowY + 6 : interactive ? 6 : -10, "px"),
34363
+ _b[arrowXRule] = "".concat(arrowX !== null && arrowX !== void 0 ? arrowX : -16, "px"),
34364
+ _b[arrowYRule] = "".concat(arrowY ? arrowY + 6 : -10, "px"),
34262
34365
  _b), fill: "none" },
34263
34366
  React.createElement("rect", { x: "0", y: "0", width: "48", height: "4", strokeWidth: "0" }),
34264
34367
  React.createElement("path", { d: "M 0 3 C 12 3 18 18 24 18 C 30 18 36 3 48 3", strokeWidth: "2" })),