@geneui/components 3.0.0-next-711fc51-03102024 → 3.0.0-next-77c6918-09102024

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/ActionableList/index.js +4 -4
  2. package/AdvancedSearch/index.js +3 -3
  3. package/Alert/index.js +1 -1
  4. package/Breadcrumb/index.js +2 -2
  5. package/Card/index.js +2 -2
  6. package/CardList/index.js +9 -9
  7. package/{CellMeasurerCache-67fc611e.js → CellMeasurerCache-f5f86ede.js} +1 -1
  8. package/Charts/index.js +2 -2
  9. package/Checkbox/index.js +2 -5
  10. package/CheckboxGroup/index.js +2 -5
  11. package/CheckboxGroupWithSearch/index.js +2 -2
  12. package/ComboBox/index.js +2 -5
  13. package/Copy/index.js +2 -5
  14. package/Counter/index.js +3 -3
  15. package/DateFilter/index.js +3 -3
  16. package/DatePickerInput/index.js +3 -3
  17. package/Drawer/index.js +2 -5
  18. package/Dropdown/index.js +6 -6
  19. package/Editor/index.js +1 -1
  20. package/ExtendedInput/index.js +2 -2
  21. package/Form/index.js +5 -5
  22. package/FormableCheckbox/index.js +3 -6
  23. package/FormableDatePicker/index.js +4 -4
  24. package/FormableDropdown/index.js +5 -5
  25. package/FormableEditor/index.js +2 -2
  26. package/{FormableHOC-a4ebfd24.js → FormableHOC-85f89a81.js} +1 -1
  27. package/FormableMultiSelectDropdown/index.js +5 -5
  28. package/FormableNumberInput/index.js +3 -3
  29. package/FormableRadio/index.js +2 -2
  30. package/FormableSwitcher/index.js +2 -2
  31. package/FormableTextInput/index.js +3 -3
  32. package/FormableUploader/index.js +3 -3
  33. package/Grid/index.js +1 -1
  34. package/HelperText/index.js +2 -4
  35. package/Holder/index.js +2 -5
  36. package/Image/index.js +5 -8
  37. package/ImagePreview/index.js +2 -4
  38. package/InteractiveWidget/index.js +3 -5
  39. package/Label/index.js +3 -5
  40. package/Menu/index.js +2 -2
  41. package/MobilePopup/index.js +2 -2
  42. package/Modal/index.js +1 -1
  43. package/ModuleTitle/index.js +2 -5
  44. package/NavigationMenu/index.js +2 -2
  45. package/Notification/index.js +1 -1
  46. package/Option/index.js +2 -2
  47. package/Overlay/index.js +2 -5
  48. package/Overspread/index.js +4 -4
  49. package/Pagination/index.js +5 -5
  50. package/Pill/index.js +3 -5
  51. package/Popover/index.js +1 -1
  52. package/PopoverV2/index.js +2 -2
  53. package/Products/index.js +1 -1
  54. package/Profile/index.js +2 -2
  55. package/Radio/index.js +1 -1
  56. package/RadioGroup/index.js +1 -1
  57. package/Range/index.js +2 -2
  58. package/Scrollbar/index.js +1 -1
  59. package/Search/index.js +2 -2
  60. package/SearchWithDropdown/index.js +4 -4
  61. package/Section/index.js +1 -1
  62. package/Slider/index.js +3 -3
  63. package/Status/index.js +1 -7
  64. package/Steps/index.js +5 -5
  65. package/SuggestionList/index.js +1 -1
  66. package/Switcher/index.js +1 -1
  67. package/Table/index.js +11 -11
  68. package/TableCompositions/index.js +9 -9
  69. package/Tag/index.js +1 -1
  70. package/Textarea/index.js +2 -2
  71. package/TimePicker/index.js +3 -3
  72. package/Title/index.js +1 -1
  73. package/Toaster/index.js +1 -1
  74. package/Tooltip/index.js +1 -8
  75. package/TransferList/index.js +3 -3
  76. package/Uploader/index.js +2 -2
  77. package/ValidatableCheckbox/index.js +2 -5
  78. package/ValidatableDatePicker/index.js +3 -3
  79. package/ValidatableDropdown/index.js +4 -4
  80. package/ValidatableElements/index.js +4 -4
  81. package/ValidatableMultiSelectDropdown/index.js +4 -4
  82. package/ValidatableNumberInput/index.js +2 -2
  83. package/ValidatableRadio/index.js +1 -1
  84. package/ValidatableSwitcher/index.js +1 -1
  85. package/ValidatableTextInput/index.js +2 -2
  86. package/ValidatableTimeInput/index.js +2 -2
  87. package/ValidatableUploader/index.js +2 -2
  88. package/Widget/index.js +2 -5
  89. package/{configs-34847b77.js → configs-00612ce0.js} +1 -1
  90. package/hooks/useDeviceType.js +1 -1
  91. package/{index-5a08e021.js → index-3e0ca61d.js} +1 -1
  92. package/{index-2dbdcb45.js → index-79ed03c9.js} +3 -3
  93. package/{index-f76fd058.js → index-abbcc5bb.js} +5 -5
  94. package/{index-0c18f902.js → index-c92894e2.js} +642 -39
  95. package/index.js +9 -9
  96. package/lib/molecules/Tooltip/Tooltip.d.ts +30 -23
  97. package/package.json +1 -1
  98. package/{rangeAndSlider-6f97ee47.js → rangeAndSlider-693a3d41.js} +13 -5
  99. package/{react-beautiful-dnd.esm-1cdf39df.js → react-beautiful-dnd.esm-fa2b11a1.js} +1 -1
@@ -1,10 +1,7 @@
1
1
  import { _ as __rest } from './tslib.es6-f211516f.js';
2
2
  import * as React from 'react';
3
- import React__default, { useLayoutEffect, useEffect, useContext, useState, useMemo, Children, Fragment, cloneElement } from 'react';
3
+ import React__default, { useLayoutEffect, useEffect, useRef, useContext, useState, useMemo, Children, cloneElement, Fragment } from 'react';
4
4
  import * as ReactDOM from 'react-dom';
5
- import 'prop-types';
6
- import './dateValidation-67caec66.js';
7
- import useDeviceType from './hooks/useDeviceType.js';
8
5
  import { GeneUIDesignSystemContext } from './GeneUIProvider/index.js';
9
6
  import { s as styleInject } from './style-inject.es-746bb8ed.js';
10
7
 
@@ -354,6 +351,88 @@ async function detectOverflow(state, options) {
354
351
  };
355
352
  }
356
353
 
354
+ /**
355
+ * Provides data to position an inner element of the floating element so that it
356
+ * appears centered to the reference element.
357
+ * @see https://floating-ui.com/docs/arrow
358
+ */
359
+ const arrow$3 = options => ({
360
+ name: 'arrow',
361
+ options,
362
+ async fn(state) {
363
+ const {
364
+ x,
365
+ y,
366
+ placement,
367
+ rects,
368
+ platform,
369
+ elements,
370
+ middlewareData
371
+ } = state;
372
+ // Since `element` is required, we don't Partial<> the type.
373
+ const {
374
+ element,
375
+ padding = 0
376
+ } = evaluate(options, state) || {};
377
+ if (element == null) {
378
+ return {};
379
+ }
380
+ const paddingObject = getPaddingObject(padding);
381
+ const coords = {
382
+ x,
383
+ y
384
+ };
385
+ const axis = getAlignmentAxis(placement);
386
+ const length = getAxisLength(axis);
387
+ const arrowDimensions = await platform.getDimensions(element);
388
+ const isYAxis = axis === 'y';
389
+ const minProp = isYAxis ? 'top' : 'left';
390
+ const maxProp = isYAxis ? 'bottom' : 'right';
391
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
392
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
393
+ const startDiff = coords[axis] - rects.reference[axis];
394
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
395
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
396
+
397
+ // DOM platform can return `window` as the `offsetParent`.
398
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
399
+ clientSize = elements.floating[clientProp] || rects.floating[length];
400
+ }
401
+ const centerToReference = endDiff / 2 - startDiff / 2;
402
+
403
+ // If the padding is large enough that it causes the arrow to no longer be
404
+ // centered, modify the padding so that it is centered.
405
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
406
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
407
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
408
+
409
+ // Make sure the arrow doesn't overflow the floating element if the center
410
+ // point is outside the floating element's bounds.
411
+ const min$1 = minPadding;
412
+ const max = clientSize - arrowDimensions[length] - maxPadding;
413
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
414
+ const offset = clamp(min$1, center, max);
415
+
416
+ // If the reference is small enough that the arrow's padding causes it to
417
+ // to point to nothing for an aligned placement, adjust the offset of the
418
+ // floating element itself. To ensure `shift()` continues to take action,
419
+ // a single reset is performed when this is true.
420
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
421
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
422
+ return {
423
+ [axis]: coords[axis] + alignmentOffset,
424
+ data: {
425
+ [axis]: offset,
426
+ centerOffset: center - offset - alignmentOffset,
427
+ ...(shouldAddOffset && {
428
+ alignmentOffset
429
+ })
430
+ },
431
+ reset: shouldAddOffset
432
+ };
433
+ }
434
+ });
435
+
357
436
  /**
358
437
  * Optimizes the visibility of the floating element by flipping the `placement`
359
438
  * in order to keep it in view when the preferred placement(s) will overflow the
@@ -818,6 +897,15 @@ function isSafari() {
818
897
  // Chrome DevTools does not complain about navigator.vendor
819
898
  return /apple/i.test(navigator.vendor);
820
899
  }
900
+ function isMouseLikePointerType(pointerType, strict) {
901
+ // On some Linux machines with Chromium, mouse inputs return a `pointerType`
902
+ // of "pen": https://github.com/floating-ui/floating-ui/issues/2015
903
+ const values = ['mouse', 'pen'];
904
+ if (!strict) {
905
+ values.push('', undefined);
906
+ }
907
+ return values.includes(pointerType);
908
+ }
821
909
  function getDocument(node) {
822
910
  return (node == null ? void 0 : node.ownerDocument) || document;
823
911
  }
@@ -1966,6 +2054,13 @@ function autoUpdate(reference, floating, update, options) {
1966
2054
  };
1967
2055
  }
1968
2056
 
2057
+ /**
2058
+ * Provides data to position an inner element of the floating element so that it
2059
+ * appears centered to the reference element.
2060
+ * @see https://floating-ui.com/docs/arrow
2061
+ */
2062
+ const arrow$2 = arrow$3;
2063
+
1969
2064
  /**
1970
2065
  * Computes the `x` and `y` coordinates that will place the floating element
1971
2066
  * next to a given reference element.
@@ -2054,7 +2149,7 @@ function roundByDPR(element, value) {
2054
2149
  return Math.round(value * dpr) / dpr;
2055
2150
  }
2056
2151
 
2057
- function useLatestRef(value) {
2152
+ function useLatestRef$1(value) {
2058
2153
  const ref = React.useRef(value);
2059
2154
  index$1(() => {
2060
2155
  ref.current = value;
@@ -2115,9 +2210,9 @@ function useFloating$1(options) {
2115
2210
  const floatingRef = React.useRef(null);
2116
2211
  const dataRef = React.useRef(data);
2117
2212
  const hasWhileElementsMounted = whileElementsMounted != null;
2118
- const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2119
- const platformRef = useLatestRef(platform);
2120
- const openRef = useLatestRef(open);
2213
+ const whileElementsMountedRef = useLatestRef$1(whileElementsMounted);
2214
+ const platformRef = useLatestRef$1(platform);
2215
+ const openRef = useLatestRef$1(open);
2121
2216
  const update = React.useCallback(() => {
2122
2217
  if (!referenceRef.current || !floatingRef.current) {
2123
2218
  return;
@@ -2218,6 +2313,55 @@ function useFloating$1(options) {
2218
2313
  }), [data, update, refs, elements, floatingStyles]);
2219
2314
  }
2220
2315
 
2316
+ /**
2317
+ * Provides data to position an inner element of the floating element so that it
2318
+ * appears centered to the reference element.
2319
+ * This wraps the core `arrow` middleware to allow React refs as the element.
2320
+ * @see https://floating-ui.com/docs/arrow
2321
+ */
2322
+ const arrow$1 = options => {
2323
+ function isRef(value) {
2324
+ return {}.hasOwnProperty.call(value, 'current');
2325
+ }
2326
+ return {
2327
+ name: 'arrow',
2328
+ options,
2329
+ fn(state) {
2330
+ const {
2331
+ element,
2332
+ padding
2333
+ } = typeof options === 'function' ? options(state) : options;
2334
+ if (element && isRef(element)) {
2335
+ if (element.current != null) {
2336
+ return arrow$2({
2337
+ element: element.current,
2338
+ padding
2339
+ }).fn(state);
2340
+ }
2341
+ return {};
2342
+ }
2343
+ if (element) {
2344
+ return arrow$2({
2345
+ element,
2346
+ padding
2347
+ }).fn(state);
2348
+ }
2349
+ return {};
2350
+ }
2351
+ };
2352
+ };
2353
+
2354
+ /**
2355
+ * Provides data to position an inner element of the floating element so that it
2356
+ * appears centered to the reference element.
2357
+ * This wraps the core `arrow` middleware to allow React refs as the element.
2358
+ * @see https://floating-ui.com/docs/arrow
2359
+ */
2360
+ const arrow = (options, deps) => ({
2361
+ ...arrow$1(options),
2362
+ options: [options, deps]
2363
+ });
2364
+
2221
2365
  // https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
2222
2366
  const SafeReact = {
2223
2367
  ...React
@@ -2342,6 +2486,321 @@ function createAttribute(name) {
2342
2486
  return "data-floating-ui-" + name;
2343
2487
  }
2344
2488
 
2489
+ function useLatestRef(value) {
2490
+ const ref = useRef(value);
2491
+ index(() => {
2492
+ ref.current = value;
2493
+ });
2494
+ return ref;
2495
+ }
2496
+
2497
+ const safePolygonIdentifier = /*#__PURE__*/createAttribute('safe-polygon');
2498
+ function getDelay(value, prop, pointerType) {
2499
+ if (pointerType && !isMouseLikePointerType(pointerType)) {
2500
+ return 0;
2501
+ }
2502
+ if (typeof value === 'number') {
2503
+ return value;
2504
+ }
2505
+ return value == null ? void 0 : value[prop];
2506
+ }
2507
+ /**
2508
+ * Opens the floating element while hovering over the reference element, like
2509
+ * CSS `:hover`.
2510
+ * @see https://floating-ui.com/docs/useHover
2511
+ */
2512
+ function useHover(context, props) {
2513
+ if (props === void 0) {
2514
+ props = {};
2515
+ }
2516
+ const {
2517
+ open,
2518
+ onOpenChange,
2519
+ dataRef,
2520
+ events,
2521
+ elements
2522
+ } = context;
2523
+ const {
2524
+ enabled = true,
2525
+ delay = 0,
2526
+ handleClose = null,
2527
+ mouseOnly = false,
2528
+ restMs = 0,
2529
+ move = true
2530
+ } = props;
2531
+ const tree = useFloatingTree();
2532
+ const parentId = useFloatingParentNodeId();
2533
+ const handleCloseRef = useLatestRef(handleClose);
2534
+ const delayRef = useLatestRef(delay);
2535
+ const openRef = useLatestRef(open);
2536
+ const pointerTypeRef = React.useRef();
2537
+ const timeoutRef = React.useRef(-1);
2538
+ const handlerRef = React.useRef();
2539
+ const restTimeoutRef = React.useRef(-1);
2540
+ const blockMouseMoveRef = React.useRef(true);
2541
+ const performedPointerEventsMutationRef = React.useRef(false);
2542
+ const unbindMouseMoveRef = React.useRef(() => {});
2543
+ const isHoverOpen = React.useCallback(() => {
2544
+ var _dataRef$current$open;
2545
+ const type = (_dataRef$current$open = dataRef.current.openEvent) == null ? void 0 : _dataRef$current$open.type;
2546
+ return (type == null ? void 0 : type.includes('mouse')) && type !== 'mousedown';
2547
+ }, [dataRef]);
2548
+
2549
+ // When closing before opening, clear the delay timeouts to cancel it
2550
+ // from showing.
2551
+ React.useEffect(() => {
2552
+ if (!enabled) return;
2553
+ function onOpenChange(_ref) {
2554
+ let {
2555
+ open
2556
+ } = _ref;
2557
+ if (!open) {
2558
+ clearTimeout(timeoutRef.current);
2559
+ clearTimeout(restTimeoutRef.current);
2560
+ blockMouseMoveRef.current = true;
2561
+ }
2562
+ }
2563
+ events.on('openchange', onOpenChange);
2564
+ return () => {
2565
+ events.off('openchange', onOpenChange);
2566
+ };
2567
+ }, [enabled, events]);
2568
+ React.useEffect(() => {
2569
+ if (!enabled) return;
2570
+ if (!handleCloseRef.current) return;
2571
+ if (!open) return;
2572
+ function onLeave(event) {
2573
+ if (isHoverOpen()) {
2574
+ onOpenChange(false, event, 'hover');
2575
+ }
2576
+ }
2577
+ const html = getDocument(elements.floating).documentElement;
2578
+ html.addEventListener('mouseleave', onLeave);
2579
+ return () => {
2580
+ html.removeEventListener('mouseleave', onLeave);
2581
+ };
2582
+ }, [elements.floating, open, onOpenChange, enabled, handleCloseRef, isHoverOpen]);
2583
+ const closeWithDelay = React.useCallback(function (event, runElseBranch, reason) {
2584
+ if (runElseBranch === void 0) {
2585
+ runElseBranch = true;
2586
+ }
2587
+ if (reason === void 0) {
2588
+ reason = 'hover';
2589
+ }
2590
+ const closeDelay = getDelay(delayRef.current, 'close', pointerTypeRef.current);
2591
+ if (closeDelay && !handlerRef.current) {
2592
+ clearTimeout(timeoutRef.current);
2593
+ timeoutRef.current = window.setTimeout(() => onOpenChange(false, event, reason), closeDelay);
2594
+ } else if (runElseBranch) {
2595
+ clearTimeout(timeoutRef.current);
2596
+ onOpenChange(false, event, reason);
2597
+ }
2598
+ }, [delayRef, onOpenChange]);
2599
+ const cleanupMouseMoveHandler = useEffectEvent(() => {
2600
+ unbindMouseMoveRef.current();
2601
+ handlerRef.current = undefined;
2602
+ });
2603
+ const clearPointerEvents = useEffectEvent(() => {
2604
+ if (performedPointerEventsMutationRef.current) {
2605
+ const body = getDocument(elements.floating).body;
2606
+ body.style.pointerEvents = '';
2607
+ body.removeAttribute(safePolygonIdentifier);
2608
+ performedPointerEventsMutationRef.current = false;
2609
+ }
2610
+ });
2611
+
2612
+ // Registering the mouse events on the reference directly to bypass React's
2613
+ // delegation system. If the cursor was on a disabled element and then entered
2614
+ // the reference (no gap), `mouseenter` doesn't fire in the delegation system.
2615
+ React.useEffect(() => {
2616
+ if (!enabled) return;
2617
+ function isClickLikeOpenEvent() {
2618
+ return dataRef.current.openEvent ? ['click', 'mousedown'].includes(dataRef.current.openEvent.type) : false;
2619
+ }
2620
+ function onMouseEnter(event) {
2621
+ clearTimeout(timeoutRef.current);
2622
+ blockMouseMoveRef.current = false;
2623
+ if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current) || restMs > 0 && !getDelay(delayRef.current, 'open')) {
2624
+ return;
2625
+ }
2626
+ const openDelay = getDelay(delayRef.current, 'open', pointerTypeRef.current);
2627
+ if (openDelay) {
2628
+ timeoutRef.current = window.setTimeout(() => {
2629
+ if (!openRef.current) {
2630
+ onOpenChange(true, event, 'hover');
2631
+ }
2632
+ }, openDelay);
2633
+ } else {
2634
+ onOpenChange(true, event, 'hover');
2635
+ }
2636
+ }
2637
+ function onMouseLeave(event) {
2638
+ if (isClickLikeOpenEvent()) return;
2639
+ unbindMouseMoveRef.current();
2640
+ const doc = getDocument(elements.floating);
2641
+ clearTimeout(restTimeoutRef.current);
2642
+ if (handleCloseRef.current && dataRef.current.floatingContext) {
2643
+ // Prevent clearing `onScrollMouseLeave` timeout.
2644
+ if (!open) {
2645
+ clearTimeout(timeoutRef.current);
2646
+ }
2647
+ handlerRef.current = handleCloseRef.current({
2648
+ ...dataRef.current.floatingContext,
2649
+ tree,
2650
+ x: event.clientX,
2651
+ y: event.clientY,
2652
+ onClose() {
2653
+ clearPointerEvents();
2654
+ cleanupMouseMoveHandler();
2655
+ closeWithDelay(event, true, 'safe-polygon');
2656
+ }
2657
+ });
2658
+ const handler = handlerRef.current;
2659
+ doc.addEventListener('mousemove', handler);
2660
+ unbindMouseMoveRef.current = () => {
2661
+ doc.removeEventListener('mousemove', handler);
2662
+ };
2663
+ return;
2664
+ }
2665
+
2666
+ // Allow interactivity without `safePolygon` on touch devices. With a
2667
+ // pointer, a short close delay is an alternative, so it should work
2668
+ // consistently.
2669
+ const shouldClose = pointerTypeRef.current === 'touch' ? !contains(elements.floating, event.relatedTarget) : true;
2670
+ if (shouldClose) {
2671
+ closeWithDelay(event);
2672
+ }
2673
+ }
2674
+
2675
+ // Ensure the floating element closes after scrolling even if the pointer
2676
+ // did not move.
2677
+ // https://github.com/floating-ui/floating-ui/discussions/1692
2678
+ function onScrollMouseLeave(event) {
2679
+ if (isClickLikeOpenEvent()) return;
2680
+ if (!dataRef.current.floatingContext) return;
2681
+ handleCloseRef.current == null || handleCloseRef.current({
2682
+ ...dataRef.current.floatingContext,
2683
+ tree,
2684
+ x: event.clientX,
2685
+ y: event.clientY,
2686
+ onClose() {
2687
+ clearPointerEvents();
2688
+ cleanupMouseMoveHandler();
2689
+ closeWithDelay(event);
2690
+ }
2691
+ })(event);
2692
+ }
2693
+ if (isElement(elements.domReference)) {
2694
+ var _elements$floating;
2695
+ const ref = elements.domReference;
2696
+ open && ref.addEventListener('mouseleave', onScrollMouseLeave);
2697
+ (_elements$floating = elements.floating) == null || _elements$floating.addEventListener('mouseleave', onScrollMouseLeave);
2698
+ move && ref.addEventListener('mousemove', onMouseEnter, {
2699
+ once: true
2700
+ });
2701
+ ref.addEventListener('mouseenter', onMouseEnter);
2702
+ ref.addEventListener('mouseleave', onMouseLeave);
2703
+ return () => {
2704
+ var _elements$floating2;
2705
+ open && ref.removeEventListener('mouseleave', onScrollMouseLeave);
2706
+ (_elements$floating2 = elements.floating) == null || _elements$floating2.removeEventListener('mouseleave', onScrollMouseLeave);
2707
+ move && ref.removeEventListener('mousemove', onMouseEnter);
2708
+ ref.removeEventListener('mouseenter', onMouseEnter);
2709
+ ref.removeEventListener('mouseleave', onMouseLeave);
2710
+ };
2711
+ }
2712
+ }, [elements, enabled, context, mouseOnly, restMs, move, closeWithDelay, cleanupMouseMoveHandler, clearPointerEvents, onOpenChange, open, openRef, tree, delayRef, handleCloseRef, dataRef]);
2713
+
2714
+ // Block pointer-events of every element other than the reference and floating
2715
+ // while the floating element is open and has a `handleClose` handler. Also
2716
+ // handles nested floating elements.
2717
+ // https://github.com/floating-ui/floating-ui/issues/1722
2718
+ index(() => {
2719
+ var _handleCloseRef$curre;
2720
+ if (!enabled) return;
2721
+ if (open && (_handleCloseRef$curre = handleCloseRef.current) != null && _handleCloseRef$curre.__options.blockPointerEvents && isHoverOpen()) {
2722
+ performedPointerEventsMutationRef.current = true;
2723
+ const floatingEl = elements.floating;
2724
+ if (isElement(elements.domReference) && floatingEl) {
2725
+ var _tree$nodesRef$curren;
2726
+ const body = getDocument(elements.floating).body;
2727
+ body.setAttribute(safePolygonIdentifier, '');
2728
+ const ref = elements.domReference;
2729
+ const parentFloating = tree == null || (_tree$nodesRef$curren = tree.nodesRef.current.find(node => node.id === parentId)) == null || (_tree$nodesRef$curren = _tree$nodesRef$curren.context) == null ? void 0 : _tree$nodesRef$curren.elements.floating;
2730
+ if (parentFloating) {
2731
+ parentFloating.style.pointerEvents = '';
2732
+ }
2733
+ body.style.pointerEvents = 'none';
2734
+ ref.style.pointerEvents = 'auto';
2735
+ floatingEl.style.pointerEvents = 'auto';
2736
+ return () => {
2737
+ body.style.pointerEvents = '';
2738
+ ref.style.pointerEvents = '';
2739
+ floatingEl.style.pointerEvents = '';
2740
+ };
2741
+ }
2742
+ }
2743
+ }, [enabled, open, parentId, elements, tree, handleCloseRef, isHoverOpen]);
2744
+ index(() => {
2745
+ if (!open) {
2746
+ pointerTypeRef.current = undefined;
2747
+ cleanupMouseMoveHandler();
2748
+ clearPointerEvents();
2749
+ }
2750
+ }, [open, cleanupMouseMoveHandler, clearPointerEvents]);
2751
+ React.useEffect(() => {
2752
+ return () => {
2753
+ cleanupMouseMoveHandler();
2754
+ clearTimeout(timeoutRef.current);
2755
+ clearTimeout(restTimeoutRef.current);
2756
+ clearPointerEvents();
2757
+ };
2758
+ }, [enabled, elements.domReference, cleanupMouseMoveHandler, clearPointerEvents]);
2759
+ const reference = React.useMemo(() => {
2760
+ function setPointerRef(event) {
2761
+ pointerTypeRef.current = event.pointerType;
2762
+ }
2763
+ return {
2764
+ onPointerDown: setPointerRef,
2765
+ onPointerEnter: setPointerRef,
2766
+ onMouseMove(event) {
2767
+ const {
2768
+ nativeEvent
2769
+ } = event;
2770
+ function handleMouseMove() {
2771
+ if (!blockMouseMoveRef.current && !openRef.current) {
2772
+ onOpenChange(true, nativeEvent, 'hover');
2773
+ }
2774
+ }
2775
+ if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current)) {
2776
+ return;
2777
+ }
2778
+ if (open || restMs === 0) {
2779
+ return;
2780
+ }
2781
+ clearTimeout(restTimeoutRef.current);
2782
+ if (pointerTypeRef.current === 'touch') {
2783
+ handleMouseMove();
2784
+ } else {
2785
+ restTimeoutRef.current = window.setTimeout(handleMouseMove, restMs);
2786
+ }
2787
+ }
2788
+ };
2789
+ }, [mouseOnly, onOpenChange, open, openRef, restMs]);
2790
+ const floating = React.useMemo(() => ({
2791
+ onMouseEnter() {
2792
+ clearTimeout(timeoutRef.current);
2793
+ },
2794
+ onMouseLeave(event) {
2795
+ closeWithDelay(event.nativeEvent, false);
2796
+ }
2797
+ }), [closeWithDelay]);
2798
+ return React.useMemo(() => enabled ? {
2799
+ reference,
2800
+ floating
2801
+ } : {}, [enabled, reference, floating]);
2802
+ }
2803
+
2345
2804
  const getTabbableOptions = () => ({
2346
2805
  getShadowRoot: true,
2347
2806
  displayCheck:
@@ -2613,6 +3072,8 @@ function FloatingPortal(props) {
2613
3072
  }
2614
3073
  const usePortalContext = () => React.useContext(PortalContext);
2615
3074
 
3075
+ const FOCUSABLE_ATTRIBUTE = 'data-floating-ui-focusable';
3076
+
2616
3077
  function useFloatingRootContext(options) {
2617
3078
  const {
2618
3079
  open = false,
@@ -2758,6 +3219,93 @@ function useFloating(options) {
2758
3219
  }), [position, refs, elements, context]);
2759
3220
  }
2760
3221
 
3222
+ const ACTIVE_KEY = 'active';
3223
+ const SELECTED_KEY = 'selected';
3224
+ function mergeProps(userProps, propsList, elementKey) {
3225
+ const map = new Map();
3226
+ const isItem = elementKey === 'item';
3227
+ let domUserProps = userProps;
3228
+ if (isItem && userProps) {
3229
+ const {
3230
+ [ACTIVE_KEY]: _,
3231
+ [SELECTED_KEY]: __,
3232
+ ...validProps
3233
+ } = userProps;
3234
+ domUserProps = validProps;
3235
+ }
3236
+ return {
3237
+ ...(elementKey === 'floating' && {
3238
+ tabIndex: -1,
3239
+ [FOCUSABLE_ATTRIBUTE]: ''
3240
+ }),
3241
+ ...domUserProps,
3242
+ ...propsList.map(value => {
3243
+ const propsOrGetProps = value ? value[elementKey] : null;
3244
+ if (typeof propsOrGetProps === 'function') {
3245
+ return userProps ? propsOrGetProps(userProps) : null;
3246
+ }
3247
+ return propsOrGetProps;
3248
+ }).concat(userProps).reduce((acc, props) => {
3249
+ if (!props) {
3250
+ return acc;
3251
+ }
3252
+ Object.entries(props).forEach(_ref => {
3253
+ let [key, value] = _ref;
3254
+ if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) {
3255
+ return;
3256
+ }
3257
+ if (key.indexOf('on') === 0) {
3258
+ if (!map.has(key)) {
3259
+ map.set(key, []);
3260
+ }
3261
+ if (typeof value === 'function') {
3262
+ var _map$get;
3263
+ (_map$get = map.get(key)) == null || _map$get.push(value);
3264
+ acc[key] = function () {
3265
+ var _map$get2;
3266
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3267
+ args[_key] = arguments[_key];
3268
+ }
3269
+ return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map(fn => fn(...args)).find(val => val !== undefined);
3270
+ };
3271
+ }
3272
+ } else {
3273
+ acc[key] = value;
3274
+ }
3275
+ });
3276
+ return acc;
3277
+ }, {})
3278
+ };
3279
+ }
3280
+ /**
3281
+ * Merges an array of interaction hooks' props into prop getters, allowing
3282
+ * event handler functions to be composed together without overwriting one
3283
+ * another.
3284
+ * @see https://floating-ui.com/docs/useInteractions
3285
+ */
3286
+ function useInteractions(propsList) {
3287
+ if (propsList === void 0) {
3288
+ propsList = [];
3289
+ }
3290
+ const referenceDeps = propsList.map(key => key == null ? void 0 : key.reference);
3291
+ const floatingDeps = propsList.map(key => key == null ? void 0 : key.floating);
3292
+ const itemDeps = propsList.map(key => key == null ? void 0 : key.item);
3293
+ const getReferenceProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'reference'),
3294
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3295
+ referenceDeps);
3296
+ const getFloatingProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'floating'),
3297
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3298
+ floatingDeps);
3299
+ const getItemProps = React.useCallback(userProps => mergeProps(userProps, propsList, 'item'),
3300
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3301
+ itemDeps);
3302
+ return React.useMemo(() => ({
3303
+ getReferenceProps,
3304
+ getFloatingProps,
3305
+ getItemProps
3306
+ }), [getReferenceProps, getFloatingProps, getItemProps]);
3307
+ }
3308
+
2761
3309
  var reactIsExports = {};
2762
3310
  var reactIs = {
2763
3311
  get exports(){ return reactIsExports; },
@@ -3029,22 +3577,44 @@ function requireReactIs_development () {
3029
3577
  }
3030
3578
  } (reactIs));
3031
3579
 
3032
- var css_248z = "[data-gene-ui-version=\"2.16.1\"] .tooltip-c-p{pointer-events:none;z-index:10}[data-gene-ui-version=\"2.16.1\"] .s-small .tooltip-c-p{padding:1.5rem}[data-gene-ui-version=\"2.16.1\"] .tooltip-wrapper{max-width:inherit}[data-gene-ui-version=\"2.16.1\"] .tooltip-content{background:rgba(var(--background-sc-rgb),.6);border-radius:.4rem;color:rgba(var(--background-rgb),.7);font:600 1.2rem/1.6rem var(--font-family);max-width:20rem;padding:.6rem 1rem;word-break:break-word}[data-gene-ui-version=\"2.16.1\"] .tooltip-content>*+*{margin:.2rem 0 0}[data-gene-ui-version=\"2.16.1\"] .s-small .tooltip-content{font:600 1rem/1.4rem var(--font-family);padding:.6rem .8rem}[data-gene-ui-version=\"2.16.1\"] .tooltip-title{color:var(--background)}";
3580
+ var css_248z = "[data-gene-ui-version=\"2.16.1\"] .tooltip{align-items:flex-start;border-radius:var(--guit-ref-radius-3xsmall);box-shadow:var(--guit-sem-shadow-floating-2-position-x-1) var(--guit-sem-shadow-floating-2-position-y-1) var(--guit-sem-shadow-floating-2-blur-1) var(--guit-sem-shadow-floating-2-spread-1) var(--guit-sem-color-floating-2-rgba-1),var(--guit-sem-shadow-floating-2-position-x-2) var(--guit-sem-shadow-floating-2-position-y-2) var(--guit-sem-shadow-floating-2-blur-2) var(--guit-sem-shadow-floating-2-spread-2) var(--guit-sem-color-floating-2-rgba-2);display:flex;gap:var(--guit-ref-spacing-3xsmall);justify-content:space-between;max-width:24rem;min-width:10rem;padding:var(--guit-ref-spacing-xsmall) var(--guit-ref-spacing-medium)}[data-gene-ui-version=\"2.16.1\"] .tooltip_position_bottom .tooltip__arrow,[data-gene-ui-version=\"2.16.1\"] .tooltip_position_top .tooltip__arrow{transform:rotateX(60deg) rotate(45deg)}[data-gene-ui-version=\"2.16.1\"] .tooltip_position_left .tooltip__arrow,[data-gene-ui-version=\"2.16.1\"] .tooltip_position_right .tooltip__arrow{transform:rotateY(60deg) rotate(45deg)}[data-gene-ui-version=\"2.16.1\"] .tooltip_color_default,[data-gene-ui-version=\"2.16.1\"] .tooltip_color_default .tooltip__arrow{background-color:var(--guit-sem-color-background-neutral-4)}[data-gene-ui-version=\"2.16.1\"] .tooltip_color_default .tooltip__icon,[data-gene-ui-version=\"2.16.1\"] .tooltip_color_default .tooltip__text{color:var(--guit-sem-color-foreground-inverse-notheme)}[data-gene-ui-version=\"2.16.1\"] .tooltip_color_inverse,[data-gene-ui-version=\"2.16.1\"] .tooltip_color_inverse .tooltip__arrow{background-color:var(--guit-sem-color-background-neutral-1)}[data-gene-ui-version=\"2.16.1\"] .tooltip_color_inverse .tooltip__icon,[data-gene-ui-version=\"2.16.1\"] .tooltip_color_inverse .tooltip__text{color:var(--guit-sem-color-foreground-neutral-2)}[data-gene-ui-version=\"2.16.1\"] .tooltip__arrow{height:10px;position:absolute;width:10px}[data-gene-ui-version=\"2.16.1\"] .tooltip__textWrapper{display:flex;flex-direction:column;gap:var(--guit-sem-font-caption-large-medium-paragraph-spacing)}[data-gene-ui-version=\"2.16.1\"] .tooltip__text{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;font-family:var(--guit-sem-font-caption-large-medium-font-family);font-size:var(--guit-sem-font-caption-large-medium-font-size);font-weight:var(--guit-sem-font-caption-large-medium-font-weight);letter-spacing:var(--guit-sem-font-caption-large-medium-letter-spacing);line-height:var(--guit-sem-font-caption-large-medium-llne-height);overflow:hidden;word-break:break-word}[data-gene-ui-version=\"2.16.1\"] .tooltip__icon{align-items:center;display:flex;flex:0 0 auto;justify-content:center}";
3033
3581
  styleInject(css_248z);
3034
3582
 
3035
- const positions = ['top', 'right', 'bottom', 'left'];
3036
- const FindAndSetRef = (children, childProps, componentRef) => {
3583
+ const positions = [
3584
+ 'top',
3585
+ 'right',
3586
+ 'bottom',
3587
+ 'left',
3588
+ 'top-start',
3589
+ 'top-end',
3590
+ 'right-start',
3591
+ 'right-end',
3592
+ 'bottom-start',
3593
+ 'bottom-end',
3594
+ 'left-start',
3595
+ 'left-end'
3596
+ ];
3597
+ const correctPosition = {
3598
+ 'bottom-center': 'bottom',
3599
+ 'bottom-left': 'bottom-start',
3600
+ 'bottom-right': 'bottom-end',
3601
+ 'left-bottom': 'left-end',
3602
+ 'left-center': 'left',
3603
+ 'left-top': 'left-start',
3604
+ 'right-bottom': 'right-end',
3605
+ 'right-center': 'right',
3606
+ 'right-top': 'right-start',
3607
+ 'top-center': 'top',
3608
+ 'top-left': 'top-start',
3609
+ 'top-right': 'top-end'
3610
+ };
3611
+ const FindAndSetRef = (children, childProps, componentRef, checked = false) => {
3037
3612
  return Children.map(children, (node, i) => {
3038
3613
  const el = node;
3039
3614
  let newProps = Object.assign({}, childProps);
3040
- if ((el === null || el === void 0 ? void 0 : el.type) === Fragment && el.props.children) {
3041
- return FindAndSetRef(el.props.children, newProps, componentRef);
3042
- }
3043
- if (reactIsExports.isForwardRef(el)) {
3044
- return FindAndSetRef(el.type.render(el.props, el.ref), newProps, componentRef);
3045
- }
3046
3615
  if (typeof (el === null || el === void 0 ? void 0 : el.type) === 'string') {
3047
- if (!el.ref && i === 0) {
3616
+ if (!el.ref && i === 0 && !checked) {
3617
+ checked = true;
3048
3618
  newProps = Object.assign(Object.assign({}, newProps), { ref: componentRef });
3049
3619
  }
3050
3620
  return cloneElement(el, newProps);
@@ -3055,20 +3625,30 @@ const FindAndSetRef = (children, childProps, componentRef) => {
3055
3625
  }
3056
3626
  return cloneElement(el.type(el.props), newProps);
3057
3627
  }
3628
+ if ((el === null || el === void 0 ? void 0 : el.type) === Fragment && el.props.children) {
3629
+ return FindAndSetRef(el.props.children, newProps, componentRef, checked);
3630
+ }
3631
+ if (reactIsExports.isForwardRef(el)) {
3632
+ return FindAndSetRef(el.type.render(el.props, el.ref), newProps, componentRef, checked);
3633
+ }
3058
3634
  return el && cloneElement(el, newProps);
3059
3635
  });
3060
3636
  };
3637
+ /**
3638
+ A tooltip is a small, elevated surface that appears to provide contextual information when a user hovers over or focuses on a UI element.
3639
+ Tooltips should be used to offer helpful plaintext information, not to communicate system feedback. Use a popover instead if you need to deliver structured information or enable interactions.
3640
+ */
3061
3641
  const Tooltip = (_a) => {
3062
- var { children, position = 'top', size = 'default', style, text, title, customPosition, alwaysShow, padding = 5, screenType = 'desktop', isVisible = true } = _a, props = __rest(_a, ["children", "position", "size", "style", "text", "title", "customPosition", "alwaysShow", "padding", "screenType", "isVisible"]);
3063
- // @ts-ignore
3642
+ var _b;
3643
+ var { children, position = 'top', text, customPosition, alwaysShow, padding = 10, isVisible = true, appearance = 'default', Icon } = _a, props = __rest(_a, ["children", "position", "text", "customPosition", "alwaysShow", "padding", "isVisible", "appearance", "Icon"]);
3064
3644
  const { geneUIProviderRef } = useContext(GeneUIDesignSystemContext);
3065
- const { isMobile } = useDeviceType(screenType);
3066
- const [isPopoverOpen, setIsPopoverState] = useState(false);
3067
- const mouseEnterHandler = () => !alwaysShow && setIsPopoverState(true);
3068
- const mouseLeaveHandler = () => !alwaysShow && setIsPopoverState(false);
3069
- const { refs, floatingStyles, context } = useFloating({
3645
+ const [isPopoverOpen, setIsPopoverOpen] = useState(false);
3646
+ const arrowRef = useRef(null);
3647
+ const { refs, floatingStyles, context, middlewareData, placement } = useFloating({
3070
3648
  open: alwaysShow || isPopoverOpen,
3071
- placement: position,
3649
+ placement: correctPosition[position],
3650
+ onOpenChange: setIsPopoverOpen,
3651
+ platform: Object.assign(Object.assign({}, platform), { isRTL: () => false }),
3072
3652
  middleware: [
3073
3653
  offset(padding),
3074
3654
  flip({
@@ -3076,6 +3656,7 @@ const Tooltip = (_a) => {
3076
3656
  fallbackPlacements: positions,
3077
3657
  mainAxis: true
3078
3658
  }),
3659
+ arrow({ element: arrowRef }),
3079
3660
  shift(),
3080
3661
  {
3081
3662
  name: 'getCustomPosition',
@@ -3089,27 +3670,49 @@ const Tooltip = (_a) => {
3089
3670
  ],
3090
3671
  whileElementsMounted: autoUpdate
3091
3672
  });
3092
- const checkNudged = ({ nudgedLeft, nudgedTop }) => (isMobile ? !(nudgedTop || nudgedLeft) : true);
3093
- const childProps = {
3094
- onMouseEnter: mouseEnterHandler,
3095
- onMouseLeave: mouseLeaveHandler
3096
- };
3673
+ const hover = useHover(context);
3674
+ const { getReferenceProps, getFloatingProps } = useInteractions([hover]);
3675
+ const childProps = Object.assign({}, getReferenceProps());
3097
3676
  const component = useMemo(() => FindAndSetRef(children, childProps, refs.setReference), [children, childProps]);
3098
3677
  useEffect(() => {
3099
- component.forEach((element) => {
3100
- var _a;
3101
- const node = element;
3678
+ var _a;
3679
+ for (let i = 0; i < component.length; i++) {
3680
+ const node = component[i];
3681
+ if (typeof node.ref === 'function' && node.ref === refs.setReference) {
3682
+ break;
3683
+ }
3102
3684
  if ((_a = node === null || node === void 0 ? void 0 : node.ref) === null || _a === void 0 ? void 0 : _a.current) {
3103
3685
  refs.setReference(node.ref.current);
3686
+ break;
3104
3687
  }
3105
- });
3688
+ }
3106
3689
  }, [component]);
3690
+ const currentDirection = placement.split('-')[0];
3691
+ const staticSide = {
3692
+ top: 'bottom',
3693
+ right: 'left',
3694
+ bottom: 'top',
3695
+ left: 'right'
3696
+ }[currentDirection];
3697
+ const middlewareArrowData = middlewareData.arrow;
3698
+ const offsetFromEdge = 8;
3699
+ const arrowPositions = {
3700
+ 'top-start': 'left',
3701
+ 'top-end': 'right',
3702
+ 'bottom-end': 'right',
3703
+ 'bottom-start': 'left'
3704
+ }[placement];
3705
+ const getCorrectPosition = arrowPositions
3706
+ ? { [arrowPositions]: offsetFromEdge }
3707
+ : { 'inset-inline-start': (middlewareArrowData === null || middlewareArrowData === void 0 ? void 0 : middlewareArrowData.x) || undefined };
3107
3708
  return (React__default.createElement(React__default.Fragment, null,
3108
3709
  component,
3109
- isVisible && (alwaysShow || isPopoverOpen) && (React__default.createElement(FloatingPortal, { root: geneUIProviderRef.current }, checkNudged({ nudgedLeft: context.x, nudgedTop: context.y }) && (React__default.createElement("div", Object.assign({ className: `tooltip-c-p s-${size} ${position}`, ref: refs.setFloating, style: Object.assign(Object.assign(Object.assign({}, style), floatingStyles), { zIndex: 400 //TODO: Remove after 3.0.0
3110
- }) }, props), (title || text) && (React__default.createElement("div", { className: "tooltip-content" },
3111
- title && React__default.createElement("div", { className: "tooltip-title" }, title),
3112
- text && React__default.createElement("div", { className: "tooltip-text" }, text)))))))));
3710
+ isVisible && (alwaysShow || isPopoverOpen) && (React__default.createElement(FloatingPortal, { root: geneUIProviderRef.current },
3711
+ React__default.createElement("div", Object.assign({ className: `tooltip tooltip_color_${appearance} tooltip_position_${currentDirection}`, ref: refs.setFloating, style: floatingStyles }, props, getFloatingProps()),
3712
+ React__default.createElement("div", { className: "tooltip__arrow", ref: arrowRef, style: Object.assign(Object.assign({}, getCorrectPosition), { top: (middlewareArrowData === null || middlewareArrowData === void 0 ? void 0 : middlewareArrowData.y) || undefined, [staticSide]: arrowRef.current ? `${-((_b = arrowRef === null || arrowRef === void 0 ? void 0 : arrowRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) + 5}px` : 0 }) }),
3713
+ React__default.createElement("div", { className: "tooltip__textWrapper" },
3714
+ React__default.createElement("p", { className: "tooltip__text" }, text)),
3715
+ Icon && React__default.createElement("div", { className: "tooltip__icon" }, Icon))))));
3113
3716
  };
3114
3717
 
3115
3718
  export { Tooltip as T, reactIsExports as r };