analytica-frontend-lib 1.1.56 → 1.1.58

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.
@@ -10,7 +10,8 @@ import {
10
10
  forwardRef,
11
11
  Fragment as Fragment2,
12
12
  useState,
13
- useRef
13
+ useRef,
14
+ useEffect
14
15
  } from "react";
15
16
 
16
17
  // src/utils/utils.ts
@@ -1549,6 +1550,8 @@ var CardAudio = forwardRef(
1549
1550
  const [showSpeedMenu, setShowSpeedMenu] = useState(false);
1550
1551
  const [playbackRate, setPlaybackRate] = useState(1);
1551
1552
  const audioRef = useRef(null);
1553
+ const volumeControlRef = useRef(null);
1554
+ const speedMenuRef = useRef(null);
1552
1555
  const formatTime = (time) => {
1553
1556
  const minutes = Math.floor(time / 60);
1554
1557
  const seconds = Math.floor(time % 60);
@@ -1600,9 +1603,11 @@ var CardAudio = forwardRef(
1600
1603
  };
1601
1604
  const toggleVolumeControl = () => {
1602
1605
  setShowVolumeControl(!showVolumeControl);
1606
+ setShowSpeedMenu(false);
1603
1607
  };
1604
1608
  const toggleSpeedMenu = () => {
1605
1609
  setShowSpeedMenu(!showSpeedMenu);
1610
+ setShowVolumeControl(false);
1606
1611
  };
1607
1612
  const handleSpeedChange = (speed) => {
1608
1613
  setPlaybackRate(speed);
@@ -1620,6 +1625,20 @@ var CardAudio = forwardRef(
1620
1625
  }
1621
1626
  return /* @__PURE__ */ jsx6(SpeakerHigh, { size: 24 });
1622
1627
  };
1628
+ useEffect(() => {
1629
+ const handleClickOutside = (event) => {
1630
+ if (volumeControlRef.current && !volumeControlRef.current.contains(event.target)) {
1631
+ setShowVolumeControl(false);
1632
+ }
1633
+ if (speedMenuRef.current && !speedMenuRef.current.contains(event.target)) {
1634
+ setShowSpeedMenu(false);
1635
+ }
1636
+ };
1637
+ document.addEventListener("mousedown", handleClickOutside);
1638
+ return () => {
1639
+ document.removeEventListener("mousedown", handleClickOutside);
1640
+ };
1641
+ }, []);
1623
1642
  return /* @__PURE__ */ jsxs5(
1624
1643
  CardBase,
1625
1644
  {
@@ -1708,7 +1727,7 @@ var CardAudio = forwardRef(
1708
1727
  }
1709
1728
  ) }),
1710
1729
  /* @__PURE__ */ jsx6("p", { className: "text-text-800 text-md font-medium min-w-[2.5rem]", children: formatTime(duration) }),
1711
- /* @__PURE__ */ jsxs5("div", { className: "relative h-6", children: [
1730
+ /* @__PURE__ */ jsxs5("div", { className: "relative h-6", ref: volumeControlRef, children: [
1712
1731
  /* @__PURE__ */ jsx6(
1713
1732
  "button",
1714
1733
  {
@@ -1770,7 +1789,7 @@ var CardAudio = forwardRef(
1770
1789
  }
1771
1790
  )
1772
1791
  ] }),
1773
- /* @__PURE__ */ jsxs5("div", { className: "relative h-6", children: [
1792
+ /* @__PURE__ */ jsxs5("div", { className: "relative h-6", ref: speedMenuRef, children: [
1774
1793
  /* @__PURE__ */ jsx6(
1775
1794
  "button",
1776
1795
  {