@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.umd.js CHANGED
@@ -7077,7 +7077,7 @@ function requireReactDom_development () {
7077
7077
  return a !== 0 && a < b ? a : b;
7078
7078
  }
7079
7079
  function lowerEventPriority(a, b) {
7080
- return a === 0 || a > b ? a : b;
7080
+ return a > b ? a : b;
7081
7081
  }
7082
7082
  function isHigherEventPriority(a, b) {
7083
7083
  return a !== 0 && a < b;
@@ -10198,7 +10198,7 @@ function requireReactDom_development () {
10198
10198
 
10199
10199
  var isCapturePhaseListener = false;
10200
10200
  var listenerSet = getEventListenerSet(targetElement);
10201
- var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener);
10201
+ var listenerSetKey = getListenerSetKey(domEventName);
10202
10202
 
10203
10203
  if (!listenerSet.has(listenerSetKey)) {
10204
10204
  addTrappedEventListener(targetElement, domEventName, IS_NON_DELEGATED, isCapturePhaseListener);
@@ -10595,7 +10595,7 @@ function requireReactDom_development () {
10595
10595
  }
10596
10596
  }
10597
10597
  function getListenerSetKey(domEventName, capture) {
10598
- return domEventName + "__" + (capture ? 'capture' : 'bubble');
10598
+ return domEventName + "__" + ('bubble');
10599
10599
  }
10600
10600
 
10601
10601
  var didWarnInvalidHydration = false;
@@ -31184,7 +31184,7 @@ function isMouseLikePointerType(pointerType, strict) {
31184
31184
  // On some Linux machines with Chromium, mouse inputs return a `pointerType`
31185
31185
  // of "pen": https://github.com/floating-ui/floating-ui/issues/2015
31186
31186
  const values = ['mouse', 'pen'];
31187
- if (!strict) {
31187
+ {
31188
31188
  values.push('', undefined);
31189
31189
  }
31190
31190
  return values.includes(pointerType);
@@ -31565,7 +31565,7 @@ async function detectOverflow(state, options) {
31565
31565
  * appears centered to the reference element.
31566
31566
  * @see https://floating-ui.com/docs/arrow
31567
31567
  */
31568
- const arrow$2 = options => ({
31568
+ const arrow$3 = options => ({
31569
31569
  name: 'arrow',
31570
31570
  options,
31571
31571
  async fn(state) {
@@ -31648,7 +31648,7 @@ const arrow$2 = options => ({
31648
31648
  * clipping boundary. Alternative to `autoPlacement`.
31649
31649
  * @see https://floating-ui.com/docs/flip
31650
31650
  */
31651
- const flip$1 = function (options) {
31651
+ const flip$2 = function (options) {
31652
31652
  if (options === void 0) {
31653
31653
  options = {};
31654
31654
  }
@@ -31806,7 +31806,7 @@ async function convertValueToCoords(state, options) {
31806
31806
  * object may be passed.
31807
31807
  * @see https://floating-ui.com/docs/offset
31808
31808
  */
31809
- const offset = function (options) {
31809
+ const offset$2 = function (options) {
31810
31810
  if (options === void 0) {
31811
31811
  options = 0;
31812
31812
  }
@@ -31845,7 +31845,7 @@ const offset = function (options) {
31845
31845
  * keep it in view when it will overflow the clipping boundary.
31846
31846
  * @see https://floating-ui.com/docs/shift
31847
31847
  */
31848
- const shift$1 = function (options) {
31848
+ const shift$2 = function (options) {
31849
31849
  if (options === void 0) {
31850
31850
  options = {};
31851
31851
  }
@@ -32015,8 +32015,9 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
32015
32015
  if (domElement) {
32016
32016
  const win = getWindow(domElement);
32017
32017
  const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
32018
- let currentIFrame = win.frameElement;
32019
- while (currentIFrame && offsetParent && offsetWin !== win) {
32018
+ let currentWin = win;
32019
+ let currentIFrame = currentWin.frameElement;
32020
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
32020
32021
  const iframeScale = getScale(currentIFrame);
32021
32022
  const iframeRect = currentIFrame.getBoundingClientRect();
32022
32023
  const css = getComputedStyle(currentIFrame);
@@ -32028,7 +32029,8 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
32028
32029
  height *= iframeScale.y;
32029
32030
  x += left;
32030
32031
  y += top;
32031
- currentIFrame = getWindow(currentIFrame).frameElement;
32032
+ currentWin = getWindow(currentIFrame);
32033
+ currentIFrame = currentWin.frameElement;
32032
32034
  }
32033
32035
  }
32034
32036
  return rectToClientRect({
@@ -32040,27 +32042,14 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
32040
32042
  }
32041
32043
 
32042
32044
  const topLayerSelectors = [':popover-open', ':modal'];
32043
- function topLayer(floating) {
32044
- let isTopLayer = false;
32045
- let x = 0;
32046
- let y = 0;
32047
- function setIsTopLayer(selector) {
32045
+ function isTopLayer(element) {
32046
+ return topLayerSelectors.some(selector => {
32048
32047
  try {
32049
- isTopLayer = isTopLayer || floating.matches(selector);
32050
- } catch (e) {}
32051
- }
32052
- topLayerSelectors.forEach(selector => {
32053
- setIsTopLayer(selector);
32054
- });
32055
- if (isTopLayer) {
32056
- const containingBlock = getContainingBlock(floating);
32057
- if (containingBlock) {
32058
- const rect = containingBlock.getBoundingClientRect();
32059
- x = rect.x;
32060
- y = rect.y;
32048
+ return element.matches(selector);
32049
+ } catch (e) {
32050
+ return false;
32061
32051
  }
32062
- }
32063
- return [isTopLayer, x, y];
32052
+ });
32064
32053
  }
32065
32054
 
32066
32055
  function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
@@ -32070,9 +32059,10 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
32070
32059
  offsetParent,
32071
32060
  strategy
32072
32061
  } = _ref;
32062
+ const isFixed = strategy === 'fixed';
32073
32063
  const documentElement = getDocumentElement(offsetParent);
32074
- const [isTopLayer] = elements ? topLayer(elements.floating) : [false];
32075
- if (offsetParent === documentElement || isTopLayer) {
32064
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
32065
+ if (offsetParent === documentElement || topLayer && isFixed) {
32076
32066
  return rect;
32077
32067
  }
32078
32068
  let scroll = {
@@ -32082,7 +32072,7 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
32082
32072
  let scale = createCoords(1);
32083
32073
  const offsets = createCoords(0);
32084
32074
  const isOffsetParentAnElement = isHTMLElement(offsetParent);
32085
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
32075
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
32086
32076
  if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
32087
32077
  scroll = getNodeScroll(offsetParent);
32088
32078
  }
@@ -32243,7 +32233,7 @@ function getClippingRect(_ref) {
32243
32233
  rootBoundary,
32244
32234
  strategy
32245
32235
  } = _ref;
32246
- const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
32236
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
32247
32237
  const clippingAncestors = [...elementClippingAncestors, rootBoundary];
32248
32238
  const firstClippingAncestor = clippingAncestors[0];
32249
32239
  const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
@@ -32273,7 +32263,7 @@ function getDimensions(element) {
32273
32263
  };
32274
32264
  }
32275
32265
 
32276
- function getRectRelativeToOffsetParent(element, offsetParent, strategy, floating) {
32266
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
32277
32267
  const isOffsetParentAnElement = isHTMLElement(offsetParent);
32278
32268
  const documentElement = getDocumentElement(offsetParent);
32279
32269
  const isFixed = strategy === 'fixed';
@@ -32295,17 +32285,8 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy, floating
32295
32285
  offsets.x = getWindowScrollBarX(documentElement);
32296
32286
  }
32297
32287
  }
32298
- let x = rect.left + scroll.scrollLeft - offsets.x;
32299
- let y = rect.top + scroll.scrollTop - offsets.y;
32300
- const [isTopLayer, topLayerX, topLayerY] = topLayer(floating);
32301
- if (isTopLayer) {
32302
- x += topLayerX;
32303
- y += topLayerY;
32304
- if (isOffsetParentAnElement) {
32305
- x += offsetParent.clientLeft;
32306
- y += offsetParent.clientTop;
32307
- }
32308
- }
32288
+ const x = rect.left + scroll.scrollLeft - offsets.x;
32289
+ const y = rect.top + scroll.scrollTop - offsets.y;
32309
32290
  return {
32310
32291
  x,
32311
32292
  y,
@@ -32314,6 +32295,10 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy, floating
32314
32295
  };
32315
32296
  }
32316
32297
 
32298
+ function isStaticPositioned(element) {
32299
+ return getComputedStyle(element).position === 'static';
32300
+ }
32301
+
32317
32302
  function getTrueOffsetParent(element, polyfill) {
32318
32303
  if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
32319
32304
  return null;
@@ -32327,29 +32312,41 @@ function getTrueOffsetParent(element, polyfill) {
32327
32312
  // Gets the closest ancestor positioned element. Handles some edge cases,
32328
32313
  // such as table ancestors and cross browser bugs.
32329
32314
  function getOffsetParent(element, polyfill) {
32330
- const window = getWindow(element);
32315
+ const win = getWindow(element);
32316
+ if (isTopLayer(element)) {
32317
+ return win;
32318
+ }
32331
32319
  if (!isHTMLElement(element)) {
32332
- return window;
32320
+ let svgOffsetParent = getParentNode(element);
32321
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
32322
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
32323
+ return svgOffsetParent;
32324
+ }
32325
+ svgOffsetParent = getParentNode(svgOffsetParent);
32326
+ }
32327
+ return win;
32333
32328
  }
32334
32329
  let offsetParent = getTrueOffsetParent(element, polyfill);
32335
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
32330
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
32336
32331
  offsetParent = getTrueOffsetParent(offsetParent, polyfill);
32337
32332
  }
32338
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
32339
- return window;
32333
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
32334
+ return win;
32340
32335
  }
32341
- return offsetParent || getContainingBlock(element) || window;
32336
+ return offsetParent || getContainingBlock(element) || win;
32342
32337
  }
32343
32338
 
32344
32339
  const getElementRects = async function (data) {
32345
32340
  const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
32346
32341
  const getDimensionsFn = this.getDimensions;
32342
+ const floatingDimensions = await getDimensionsFn(data.floating);
32347
32343
  return {
32348
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy, data.floating),
32344
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
32349
32345
  floating: {
32350
32346
  x: 0,
32351
32347
  y: 0,
32352
- ...(await getDimensionsFn(data.floating))
32348
+ width: floatingDimensions.width,
32349
+ height: floatingDimensions.height
32353
32350
  }
32354
32351
  };
32355
32352
  };
@@ -32419,9 +32416,11 @@ function observeMove(element, onMove) {
32419
32416
  return refresh();
32420
32417
  }
32421
32418
  if (!ratio) {
32419
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
32420
+ // to prevent an infinite loop of updates.
32422
32421
  timeoutId = setTimeout(() => {
32423
32422
  refresh(false, 1e-7);
32424
- }, 100);
32423
+ }, 1000);
32425
32424
  } else {
32426
32425
  refresh(false, ratio);
32427
32426
  }
@@ -32525,12 +32524,21 @@ function autoUpdate(reference, floating, update, options) {
32525
32524
  };
32526
32525
  }
32527
32526
 
32527
+ /**
32528
+ * Modifies the placement by translating the floating element along the
32529
+ * specified axes.
32530
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
32531
+ * object may be passed.
32532
+ * @see https://floating-ui.com/docs/offset
32533
+ */
32534
+ const offset$1 = offset$2;
32535
+
32528
32536
  /**
32529
32537
  * Optimizes the visibility of the floating element by shifting it in order to
32530
32538
  * keep it in view when it will overflow the clipping boundary.
32531
32539
  * @see https://floating-ui.com/docs/shift
32532
32540
  */
32533
- const shift = shift$1;
32541
+ const shift$1 = shift$2;
32534
32542
 
32535
32543
  /**
32536
32544
  * Optimizes the visibility of the floating element by flipping the `placement`
@@ -32538,14 +32546,14 @@ const shift = shift$1;
32538
32546
  * clipping boundary. Alternative to `autoPlacement`.
32539
32547
  * @see https://floating-ui.com/docs/flip
32540
32548
  */
32541
- const flip = flip$1;
32549
+ const flip$1 = flip$2;
32542
32550
 
32543
32551
  /**
32544
32552
  * Provides data to position an inner element of the floating element so that it
32545
32553
  * appears centered to the reference element.
32546
32554
  * @see https://floating-ui.com/docs/arrow
32547
32555
  */
32548
- const arrow$1 = arrow$2;
32556
+ const arrow$2 = arrow$3;
32549
32557
 
32550
32558
  /**
32551
32559
  * Computes the `x` and `y` coordinates that will place the floating element
@@ -32570,44 +32578,6 @@ const computePosition = (reference, floating, options) => {
32570
32578
  });
32571
32579
  };
32572
32580
 
32573
- /**
32574
- * Provides data to position an inner element of the floating element so that it
32575
- * appears centered to the reference element.
32576
- * This wraps the core `arrow` middleware to allow React refs as the element.
32577
- * @see https://floating-ui.com/docs/arrow
32578
- */
32579
- const arrow = options => {
32580
- function isRef(value) {
32581
- return {}.hasOwnProperty.call(value, 'current');
32582
- }
32583
- return {
32584
- name: 'arrow',
32585
- options,
32586
- fn(state) {
32587
- const {
32588
- element,
32589
- padding
32590
- } = typeof options === 'function' ? options(state) : options;
32591
- if (element && isRef(element)) {
32592
- if (element.current != null) {
32593
- return arrow$1({
32594
- element: element.current,
32595
- padding
32596
- }).fn(state);
32597
- }
32598
- return {};
32599
- }
32600
- if (element) {
32601
- return arrow$1({
32602
- element,
32603
- padding
32604
- }).fn(state);
32605
- }
32606
- return {};
32607
- }
32608
- };
32609
- };
32610
-
32611
32581
  var index$1 = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
32612
32582
 
32613
32583
  // Fork of `fast-deep-equal` that only does the comparisons we need and compares
@@ -32657,8 +32627,6 @@ function deepEqual(a, b) {
32657
32627
  }
32658
32628
  return true;
32659
32629
  }
32660
-
32661
- // biome-ignore lint/suspicious/noSelfCompare: in source
32662
32630
  return a !== a && b !== b;
32663
32631
  }
32664
32632
 
@@ -32779,8 +32747,6 @@ function useFloating$1(options) {
32779
32747
  isMountedRef.current = false;
32780
32748
  };
32781
32749
  }, []);
32782
-
32783
- // biome-ignore lint/correctness/useExhaustiveDependencies: `hasWhileElementsMounted` is intentionally included.
32784
32750
  index$1(() => {
32785
32751
  if (referenceEl) referenceRef.current = referenceEl;
32786
32752
  if (floatingEl) floatingRef.current = floatingEl;
@@ -32836,8 +32802,94 @@ function useFloating$1(options) {
32836
32802
  }), [data, update, refs, elements, floatingStyles]);
32837
32803
  }
32838
32804
 
32839
- // `toString()` prevents bundlers from trying to `import { useInsertionEffect } from 'react'`
32840
- const useInsertionEffect = React__namespace[/*#__PURE__*/'useInsertionEffect'.toString()];
32805
+ /**
32806
+ * Provides data to position an inner element of the floating element so that it
32807
+ * appears centered to the reference element.
32808
+ * This wraps the core `arrow` middleware to allow React refs as the element.
32809
+ * @see https://floating-ui.com/docs/arrow
32810
+ */
32811
+ const arrow$1 = options => {
32812
+ function isRef(value) {
32813
+ return {}.hasOwnProperty.call(value, 'current');
32814
+ }
32815
+ return {
32816
+ name: 'arrow',
32817
+ options,
32818
+ fn(state) {
32819
+ const {
32820
+ element,
32821
+ padding
32822
+ } = typeof options === 'function' ? options(state) : options;
32823
+ if (element && isRef(element)) {
32824
+ if (element.current != null) {
32825
+ return arrow$2({
32826
+ element: element.current,
32827
+ padding
32828
+ }).fn(state);
32829
+ }
32830
+ return {};
32831
+ }
32832
+ if (element) {
32833
+ return arrow$2({
32834
+ element,
32835
+ padding
32836
+ }).fn(state);
32837
+ }
32838
+ return {};
32839
+ }
32840
+ };
32841
+ };
32842
+
32843
+ /**
32844
+ * Modifies the placement by translating the floating element along the
32845
+ * specified axes.
32846
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
32847
+ * object may be passed.
32848
+ * @see https://floating-ui.com/docs/offset
32849
+ */
32850
+ const offset = (options, deps) => ({
32851
+ ...offset$1(options),
32852
+ options: [options, deps]
32853
+ });
32854
+
32855
+ /**
32856
+ * Optimizes the visibility of the floating element by shifting it in order to
32857
+ * keep it in view when it will overflow the clipping boundary.
32858
+ * @see https://floating-ui.com/docs/shift
32859
+ */
32860
+ const shift = (options, deps) => ({
32861
+ ...shift$1(options),
32862
+ options: [options, deps]
32863
+ });
32864
+
32865
+ /**
32866
+ * Optimizes the visibility of the floating element by flipping the `placement`
32867
+ * in order to keep it in view when the preferred placement(s) will overflow the
32868
+ * clipping boundary. Alternative to `autoPlacement`.
32869
+ * @see https://floating-ui.com/docs/flip
32870
+ */
32871
+ const flip = (options, deps) => ({
32872
+ ...flip$1(options),
32873
+ options: [options, deps]
32874
+ });
32875
+
32876
+ /**
32877
+ * Provides data to position an inner element of the floating element so that it
32878
+ * appears centered to the reference element.
32879
+ * This wraps the core `arrow` middleware to allow React refs as the element.
32880
+ * @see https://floating-ui.com/docs/arrow
32881
+ */
32882
+ const arrow = (options, deps) => ({
32883
+ ...arrow$1(options),
32884
+ options: [options, deps]
32885
+ });
32886
+
32887
+ // https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
32888
+ const SafeReact = {
32889
+ ...React__namespace
32890
+ };
32891
+
32892
+ const useInsertionEffect = SafeReact.useInsertionEffect;
32841
32893
  const useSafeInsertionEffect = useInsertionEffect || (fn => fn());
32842
32894
  function useEffectEvent(callback) {
32843
32895
  const ref = React__namespace.useRef(() => {
@@ -32860,26 +32912,23 @@ var index = typeof document !== 'undefined' ? React.useLayoutEffect : React.useE
32860
32912
 
32861
32913
  let serverHandoffComplete = false;
32862
32914
  let count = 0;
32863
- const genId = () => "floating-ui-" + count++;
32915
+ const genId = () => // Ensure the id is unique with multiple independent versions of Floating UI
32916
+ // on <React 18
32917
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++;
32864
32918
  function useFloatingId() {
32865
32919
  const [id, setId] = React__namespace.useState(() => serverHandoffComplete ? genId() : undefined);
32866
-
32867
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
32868
32920
  index(() => {
32869
32921
  if (id == null) {
32870
32922
  setId(genId());
32871
32923
  }
32924
+ // eslint-disable-next-line react-hooks/exhaustive-deps
32872
32925
  }, []);
32873
32926
  React__namespace.useEffect(() => {
32874
- if (!serverHandoffComplete) {
32875
- serverHandoffComplete = true;
32876
- }
32927
+ serverHandoffComplete = true;
32877
32928
  }, []);
32878
32929
  return id;
32879
32930
  }
32880
-
32881
- // `toString()` prevents bundlers from trying to `import { useId } from 'react'`
32882
- const useReactId = React__namespace[/*#__PURE__*/'useId'.toString()];
32931
+ const useReactId = SafeReact.useId;
32883
32932
 
32884
32933
  /**
32885
32934
  * Uses React 18's built-in `useId()` when available, or falls back to a
@@ -32889,6 +32938,23 @@ const useReactId = React__namespace[/*#__PURE__*/'useId'.toString()];
32889
32938
  */
32890
32939
  const useId = useReactId || useFloatingId;
32891
32940
 
32941
+ let devMessageSet;
32942
+ if (process.env.NODE_ENV !== "production") {
32943
+ devMessageSet = /*#__PURE__*/new Set();
32944
+ }
32945
+ function error() {
32946
+ var _devMessageSet3;
32947
+ for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
32948
+ messages[_key2] = arguments[_key2];
32949
+ }
32950
+ const message = "Floating UI: " + messages.join(' ');
32951
+ if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
32952
+ var _devMessageSet4;
32953
+ (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
32954
+ console.error(message);
32955
+ }
32956
+ }
32957
+
32892
32958
  function createPubSub() {
32893
32959
  const map = new Map();
32894
32960
  return {
@@ -32962,8 +33028,7 @@ function useHover(context, props) {
32962
33028
  elements: {
32963
33029
  domReference,
32964
33030
  floating
32965
- },
32966
- refs
33031
+ }
32967
33032
  } = context;
32968
33033
  const {
32969
33034
  enabled = true,
@@ -32978,9 +33043,9 @@ function useHover(context, props) {
32978
33043
  const handleCloseRef = useLatestRef(handleClose);
32979
33044
  const delayRef = useLatestRef(delay);
32980
33045
  const pointerTypeRef = React__namespace.useRef();
32981
- const timeoutRef = React__namespace.useRef();
33046
+ const timeoutRef = React__namespace.useRef(-1);
32982
33047
  const handlerRef = React__namespace.useRef();
32983
- const restTimeoutRef = React__namespace.useRef();
33048
+ const restTimeoutRef = React__namespace.useRef(-1);
32984
33049
  const blockMouseMoveRef = React__namespace.useRef(true);
32985
33050
  const performedPointerEventsMutationRef = React__namespace.useRef(false);
32986
33051
  const unbindMouseMoveRef = React__namespace.useRef(() => {});
@@ -33036,24 +33101,24 @@ function useHover(context, props) {
33036
33101
  const closeDelay = getDelay(delayRef.current, 'close', pointerTypeRef.current);
33037
33102
  if (closeDelay && !handlerRef.current) {
33038
33103
  clearTimeout(timeoutRef.current);
33039
- timeoutRef.current = setTimeout(() => onOpenChange(false, event, reason), closeDelay);
33104
+ timeoutRef.current = window.setTimeout(() => onOpenChange(false, event, reason), closeDelay);
33040
33105
  } else if (runElseBranch) {
33041
33106
  clearTimeout(timeoutRef.current);
33042
33107
  onOpenChange(false, event, reason);
33043
33108
  }
33044
33109
  }, [delayRef, onOpenChange]);
33045
- const cleanupMouseMoveHandler = React__namespace.useCallback(() => {
33110
+ const cleanupMouseMoveHandler = useEffectEvent(() => {
33046
33111
  unbindMouseMoveRef.current();
33047
33112
  handlerRef.current = undefined;
33048
- }, []);
33049
- const clearPointerEvents = React__namespace.useCallback(() => {
33113
+ });
33114
+ const clearPointerEvents = useEffectEvent(() => {
33050
33115
  if (performedPointerEventsMutationRef.current) {
33051
- const body = getDocument(refs.floating.current).body;
33116
+ const body = getDocument(floating).body;
33052
33117
  body.style.pointerEvents = '';
33053
33118
  body.removeAttribute(safePolygonIdentifier);
33054
33119
  performedPointerEventsMutationRef.current = false;
33055
33120
  }
33056
- }, [refs]);
33121
+ });
33057
33122
 
33058
33123
  // Registering the mouse events on the reference directly to bypass React's
33059
33124
  // delegation system. If the cursor was on a disabled element and then entered
@@ -33068,12 +33133,12 @@ function useHover(context, props) {
33068
33133
  function onMouseEnter(event) {
33069
33134
  clearTimeout(timeoutRef.current);
33070
33135
  blockMouseMoveRef.current = false;
33071
- if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current) || restMs > 0 && getDelay(delayRef.current, 'open') === 0) {
33136
+ if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current) || restMs > 0 && !getDelay(delayRef.current, 'open')) {
33072
33137
  return;
33073
33138
  }
33074
33139
  const openDelay = getDelay(delayRef.current, 'open', pointerTypeRef.current);
33075
33140
  if (openDelay) {
33076
- timeoutRef.current = setTimeout(() => {
33141
+ timeoutRef.current = window.setTimeout(() => {
33077
33142
  onOpenChange(true, event, 'hover');
33078
33143
  }, openDelay);
33079
33144
  } else {
@@ -33081,19 +33146,17 @@ function useHover(context, props) {
33081
33146
  }
33082
33147
  }
33083
33148
  function onMouseLeave(event) {
33084
- if (isClickLikeOpenEvent()) {
33085
- return;
33086
- }
33149
+ if (isClickLikeOpenEvent()) return;
33087
33150
  unbindMouseMoveRef.current();
33088
33151
  const doc = getDocument(floating);
33089
33152
  clearTimeout(restTimeoutRef.current);
33090
- if (handleCloseRef.current) {
33153
+ if (handleCloseRef.current && dataRef.current.floatingContext) {
33091
33154
  // Prevent clearing `onScrollMouseLeave` timeout.
33092
33155
  if (!open) {
33093
33156
  clearTimeout(timeoutRef.current);
33094
33157
  }
33095
33158
  handlerRef.current = handleCloseRef.current({
33096
- ...context,
33159
+ ...dataRef.current.floatingContext,
33097
33160
  tree,
33098
33161
  x: event.clientX,
33099
33162
  y: event.clientY,
@@ -33124,11 +33187,10 @@ function useHover(context, props) {
33124
33187
  // did not move.
33125
33188
  // https://github.com/floating-ui/floating-ui/discussions/1692
33126
33189
  function onScrollMouseLeave(event) {
33127
- if (isClickLikeOpenEvent()) {
33128
- return;
33129
- }
33190
+ if (isClickLikeOpenEvent()) return;
33191
+ if (!dataRef.current.floatingContext) return;
33130
33192
  handleCloseRef.current == null || handleCloseRef.current({
33131
- ...context,
33193
+ ...dataRef.current.floatingContext,
33132
33194
  tree,
33133
33195
  x: event.clientX,
33134
33196
  y: event.clientY,
@@ -33195,8 +33257,6 @@ function useHover(context, props) {
33195
33257
  clearPointerEvents();
33196
33258
  }
33197
33259
  }, [open, cleanupMouseMoveHandler, clearPointerEvents]);
33198
-
33199
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
33200
33260
  React__namespace.useEffect(() => {
33201
33261
  return () => {
33202
33262
  cleanupMouseMoveHandler();
@@ -33217,15 +33277,23 @@ function useHover(context, props) {
33217
33277
  onPointerDown: setPointerRef,
33218
33278
  onPointerEnter: setPointerRef,
33219
33279
  onMouseMove(event) {
33280
+ function handleMouseMove() {
33281
+ if (!blockMouseMoveRef.current) {
33282
+ onOpenChange(true, event.nativeEvent, 'hover');
33283
+ }
33284
+ }
33285
+ if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current)) {
33286
+ return;
33287
+ }
33220
33288
  if (open || restMs === 0) {
33221
33289
  return;
33222
33290
  }
33223
33291
  clearTimeout(restTimeoutRef.current);
33224
- restTimeoutRef.current = setTimeout(() => {
33225
- if (!blockMouseMoveRef.current) {
33226
- onOpenChange(true, event.nativeEvent, 'hover');
33227
- }
33228
- }, restMs);
33292
+ if (pointerTypeRef.current === 'touch') {
33293
+ handleMouseMove();
33294
+ } else {
33295
+ restTimeoutRef.current = window.setTimeout(handleMouseMove, restMs);
33296
+ }
33229
33297
  }
33230
33298
  },
33231
33299
  floating: {
@@ -33237,7 +33305,7 @@ function useHover(context, props) {
33237
33305
  }
33238
33306
  }
33239
33307
  };
33240
- }, [enabled, restMs, open, onOpenChange, closeWithDelay]);
33308
+ }, [enabled, mouseOnly, open, restMs, onOpenChange, closeWithDelay]);
33241
33309
  }
33242
33310
 
33243
33311
  function getChildren(nodes, id) {
@@ -33288,7 +33356,6 @@ function useDismiss(context, props) {
33288
33356
  const {
33289
33357
  open,
33290
33358
  onOpenChange,
33291
- nodeId,
33292
33359
  elements: {
33293
33360
  reference,
33294
33361
  domReference,
@@ -33321,9 +33388,11 @@ function useDismiss(context, props) {
33321
33388
  outsidePress: outsidePressCapture
33322
33389
  } = normalizeProp(capture);
33323
33390
  const closeOnEscapeKeyDown = useEffectEvent(event => {
33391
+ var _dataRef$current$floa;
33324
33392
  if (!open || !enabled || !escapeKey || event.key !== 'Escape') {
33325
33393
  return;
33326
33394
  }
33395
+ const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
33327
33396
  const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
33328
33397
  if (!escapeKeyBubbles) {
33329
33398
  event.stopPropagation();
@@ -33353,6 +33422,7 @@ function useDismiss(context, props) {
33353
33422
  (_getTarget2 = getTarget(event)) == null || _getTarget2.addEventListener('keydown', callback);
33354
33423
  });
33355
33424
  const closeOnPressOutside = useEffectEvent(event => {
33425
+ var _dataRef$current$floa2;
33356
33426
  // Given developers can stop the propagation of the synthetic event,
33357
33427
  // we can only be confident with a positive value.
33358
33428
  const insideReactTree = insideReactTreeRef.current;
@@ -33418,6 +33488,7 @@ function useDismiss(context, props) {
33418
33488
  return;
33419
33489
  }
33420
33490
  }
33491
+ const nodeId = (_dataRef$current$floa2 = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa2.nodeId;
33421
33492
  const targetIsInsideChildren = tree && getChildren(tree.nodesRef.current, nodeId).some(node => {
33422
33493
  var _node$context;
33423
33494
  return isEventTargetWithin(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating);
@@ -33493,8 +33564,6 @@ function useDismiss(context, props) {
33493
33564
  });
33494
33565
  };
33495
33566
  }, [dataRef, floating, domReference, reference, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture]);
33496
-
33497
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
33498
33567
  React__namespace.useEffect(() => {
33499
33568
  insideReactTreeRef.current = false;
33500
33569
  }, [outsidePress, outsidePressEvent]);
@@ -33527,9 +33596,50 @@ function useDismiss(context, props) {
33527
33596
  }, [enabled, referencePress, outsidePressEvent, referencePressEvent, onOpenChange, closeOnEscapeKeyDown]);
33528
33597
  }
33529
33598
 
33530
- let devMessageSet;
33531
- if (process.env.NODE_ENV !== "production") {
33532
- devMessageSet = /*#__PURE__*/new Set();
33599
+ function useFloatingRootContext(options) {
33600
+ const {
33601
+ open = false,
33602
+ onOpenChange: onOpenChangeProp,
33603
+ elements: elementsProp
33604
+ } = options;
33605
+ const floatingId = useId();
33606
+ const dataRef = React__namespace.useRef({});
33607
+ const [events] = React__namespace.useState(() => createPubSub());
33608
+ const nested = useFloatingParentNodeId() != null;
33609
+ if (process.env.NODE_ENV !== "production") {
33610
+ const optionDomReference = elementsProp.reference;
33611
+ if (optionDomReference && !isElement(optionDomReference)) {
33612
+ error('Cannot pass a virtual element to the `elements.reference` option,', 'as it must be a real DOM element. Use `refs.setPositionReference()`', 'instead.');
33613
+ }
33614
+ }
33615
+ const [positionReference, setPositionReference] = React__namespace.useState(elementsProp.reference);
33616
+ const onOpenChange = useEffectEvent((open, event, reason) => {
33617
+ dataRef.current.openEvent = open ? event : undefined;
33618
+ events.emit('openchange', {
33619
+ open,
33620
+ event,
33621
+ reason,
33622
+ nested
33623
+ });
33624
+ onOpenChangeProp == null || onOpenChangeProp(open, event, reason);
33625
+ });
33626
+ const refs = React__namespace.useMemo(() => ({
33627
+ setPositionReference
33628
+ }), []);
33629
+ const elements = React__namespace.useMemo(() => ({
33630
+ reference: positionReference || elementsProp.reference || null,
33631
+ floating: elementsProp.floating || null,
33632
+ domReference: elementsProp.reference
33633
+ }), [positionReference, elementsProp.reference, elementsProp.floating]);
33634
+ return React__namespace.useMemo(() => ({
33635
+ dataRef,
33636
+ open,
33637
+ onOpenChange,
33638
+ elements,
33639
+ events,
33640
+ floatingId,
33641
+ refs
33642
+ }), [open, onOpenChange, elements, events, floatingId, refs]);
33533
33643
  }
33534
33644
 
33535
33645
  /**
@@ -33537,54 +33647,51 @@ if (process.env.NODE_ENV !== "production") {
33537
33647
  * @see https://floating-ui.com/docs/useFloating
33538
33648
  */
33539
33649
  function useFloating(options) {
33540
- var _options$elements2;
33541
33650
  if (options === void 0) {
33542
33651
  options = {};
33543
33652
  }
33544
33653
  const {
33545
- open = false,
33546
- onOpenChange: unstable_onOpenChange,
33547
33654
  nodeId
33548
33655
  } = options;
33549
- if (process.env.NODE_ENV !== "production") {
33550
- var _options$elements;
33551
- 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.';
33552
- if ((_options$elements = options.elements) != null && _options$elements.reference && !isElement(options.elements.reference)) {
33553
- var _devMessageSet;
33554
- if (!((_devMessageSet = devMessageSet) != null && _devMessageSet.has(err))) {
33555
- var _devMessageSet2;
33556
- (_devMessageSet2 = devMessageSet) == null || _devMessageSet2.add(err);
33557
- console.error(err);
33558
- }
33656
+ const internalRootContext = useFloatingRootContext({
33657
+ ...options,
33658
+ elements: {
33659
+ reference: null,
33660
+ floating: null,
33661
+ ...options.elements
33559
33662
  }
33560
- }
33663
+ });
33664
+ const rootContext = options.rootContext || internalRootContext;
33665
+ const computedElements = rootContext.elements;
33561
33666
  const [_domReference, setDomReference] = React__namespace.useState(null);
33562
- const domReference = ((_options$elements2 = options.elements) == null ? void 0 : _options$elements2.reference) || _domReference;
33563
- const position = useFloating$1(options);
33667
+ const [positionReference, _setPositionReference] = React__namespace.useState(null);
33668
+ const optionDomReference = computedElements == null ? void 0 : computedElements.reference;
33669
+ const domReference = optionDomReference || _domReference;
33670
+ const domReferenceRef = React__namespace.useRef(null);
33564
33671
  const tree = useFloatingTree();
33565
- const nested = useFloatingParentNodeId() != null;
33566
- const onOpenChange = useEffectEvent((open, event, reason) => {
33567
- if (open) {
33568
- dataRef.current.openEvent = event;
33672
+ index(() => {
33673
+ if (domReference) {
33674
+ domReferenceRef.current = domReference;
33675
+ }
33676
+ }, [domReference]);
33677
+ const position = useFloating$1({
33678
+ ...options,
33679
+ elements: {
33680
+ ...computedElements,
33681
+ ...(positionReference && {
33682
+ reference: positionReference
33683
+ })
33569
33684
  }
33570
- events.emit('openchange', {
33571
- open,
33572
- event,
33573
- reason,
33574
- nested
33575
- });
33576
- unstable_onOpenChange == null || unstable_onOpenChange(open, event, reason);
33577
33685
  });
33578
- const domReferenceRef = React__namespace.useRef(null);
33579
- const dataRef = React__namespace.useRef({});
33580
- const events = React__namespace.useState(() => createPubSub())[0];
33581
- const floatingId = useId();
33582
33686
  const setPositionReference = React__namespace.useCallback(node => {
33583
- const positionReference = isElement(node) ? {
33687
+ const computedPositionReference = isElement(node) ? {
33584
33688
  getBoundingClientRect: () => node.getBoundingClientRect(),
33585
33689
  contextElement: node
33586
33690
  } : node;
33587
- position.refs.setReference(positionReference);
33691
+ // Store the positionReference in state if the DOM reference is specified externally via the
33692
+ // `elements.reference` option. This ensures that it won't be overridden on future renders.
33693
+ _setPositionReference(computedPositionReference);
33694
+ position.refs.setReference(computedPositionReference);
33588
33695
  }, [position.refs]);
33589
33696
  const setReference = React__namespace.useCallback(node => {
33590
33697
  if (isElement(node) || node === null) {
@@ -33614,16 +33721,13 @@ function useFloating(options) {
33614
33721
  }), [position.elements, domReference]);
33615
33722
  const context = React__namespace.useMemo(() => ({
33616
33723
  ...position,
33724
+ ...rootContext,
33617
33725
  refs,
33618
33726
  elements,
33619
- dataRef,
33620
- nodeId,
33621
- floatingId,
33622
- events,
33623
- open,
33624
- onOpenChange
33625
- }), [position, nodeId, floatingId, events, open, onOpenChange, refs, elements]);
33727
+ nodeId
33728
+ }), [position, refs, elements, nodeId, rootContext]);
33626
33729
  index(() => {
33730
+ rootContext.dataRef.current.floatingContext = context;
33627
33731
  const node = tree == null ? void 0 : tree.nodesRef.current.find(node => node.id === nodeId);
33628
33732
  if (node) {
33629
33733
  node.context = context;
@@ -33650,7 +33754,7 @@ function useFocus(context, props) {
33650
33754
  open,
33651
33755
  onOpenChange,
33652
33756
  events,
33653
- refs,
33757
+ dataRef,
33654
33758
  elements: {
33655
33759
  domReference
33656
33760
  }
@@ -33750,6 +33854,7 @@ function useFocus(context, props) {
33750
33854
 
33751
33855
  // Wait for the window blur listener to fire.
33752
33856
  timeoutRef.current = window.setTimeout(() => {
33857
+ var _dataRef$current$floa;
33753
33858
  const activeEl = activeElement(domReference ? domReference.ownerDocument : document);
33754
33859
 
33755
33860
  // Focus left the page, keep it open.
@@ -33762,7 +33867,7 @@ function useFocus(context, props) {
33762
33867
  // as it will only point to the shadow host of the newly focused element
33763
33868
  // and not the element that actually has received focus if it is located
33764
33869
  // inside a shadow root.
33765
- if (contains(refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
33870
+ if (contains((_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
33766
33871
  return;
33767
33872
  }
33768
33873
  onOpenChange(false, event.nativeEvent, 'focus');
@@ -33770,7 +33875,7 @@ function useFocus(context, props) {
33770
33875
  }
33771
33876
  }
33772
33877
  };
33773
- }, [enabled, visibleOnly, domReference, refs, onOpenChange]);
33878
+ }, [enabled, visibleOnly, dataRef, domReference, onOpenChange]);
33774
33879
  }
33775
33880
 
33776
33881
  const ACTIVE_KEY = 'active';
@@ -33830,7 +33935,6 @@ function mergeProps(userProps, propsList, elementKey) {
33830
33935
  }, {})
33831
33936
  };
33832
33937
  }
33833
-
33834
33938
  /**
33835
33939
  * Merges an array of interaction hooks' props into prop getters, allowing
33836
33940
  * event handler functions to be composed together without overwriting one
@@ -33844,19 +33948,18 @@ function useInteractions(propsList) {
33844
33948
  // The dependencies are a dynamic array, so we can't use the linter's
33845
33949
  // suggestion to add it to the deps array.
33846
33950
  const deps = propsList;
33847
-
33848
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
33849
- const getReferenceProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'reference'), deps);
33850
-
33851
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
33852
- const getFloatingProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'floating'), deps);
33853
-
33854
- // biome-ignore lint/correctness/useExhaustiveDependencies: intentional
33951
+ const getReferenceProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'reference'),
33952
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33953
+ deps);
33954
+ const getFloatingProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'floating'),
33955
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33956
+ deps);
33855
33957
  const getItemProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'item'),
33856
33958
  // Granularly check for `item` changes, because the `getItemProps` getter
33857
33959
  // should be as referentially stable as possible since it may be passed as
33858
33960
  // a prop to many components. All `item` key values must therefore be
33859
33961
  // memoized.
33962
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33860
33963
  propsList.map(key => key == null ? void 0 : key.item));
33861
33964
  return React__namespace.useMemo(() => ({
33862
33965
  getReferenceProps,
@@ -34208,7 +34311,7 @@ var Tooltip = function (_a) {
34208
34311
  fn: function (obj) { return obj; },
34209
34312
  }
34210
34313
  : flip(),
34211
- offset(interactive ? 0 : 16),
34314
+ offset(16),
34212
34315
  arrow({ element: arrowRef, padding: 24 }),
34213
34316
  shift({ padding: 16 }),
34214
34317
  ],
@@ -34277,8 +34380,8 @@ var Tooltip = function (_a) {
34277
34380
  ? 'drop-shadow(0 1px 1px rgba(225, 227, 237, .3))'
34278
34381
  : 'drop-shadow(0 1px 1px rgba(225, 227, 237, .8))'
34279
34382
  },
34280
- _b[arrowXRule] = "".concat(arrowX !== null && arrowX !== void 0 ? arrowX : (interactive ? 0 : -16), "px"),
34281
- _b[arrowYRule] = "".concat(arrowY ? arrowY + 6 : interactive ? 6 : -10, "px"),
34383
+ _b[arrowXRule] = "".concat(arrowX !== null && arrowX !== void 0 ? arrowX : -16, "px"),
34384
+ _b[arrowYRule] = "".concat(arrowY ? arrowY + 6 : -10, "px"),
34282
34385
  _b), fill: "none" },
34283
34386
  React__namespace.createElement("rect", { x: "0", y: "0", width: "48", height: "4", strokeWidth: "0" }),
34284
34387
  React__namespace.createElement("path", { d: "M 0 3 C 12 3 18 18 24 18 C 30 18 36 3 48 3", strokeWidth: "2" })),