analytica-frontend-lib 1.1.12 → 1.1.14

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.mjs CHANGED
@@ -4655,6 +4655,8 @@ var CardAudio = forwardRef12(
4655
4655
  const [duration, setDuration] = useState8(0);
4656
4656
  const [volume, setVolume] = useState8(1);
4657
4657
  const [showVolumeControl, setShowVolumeControl] = useState8(false);
4658
+ const [showSpeedMenu, setShowSpeedMenu] = useState8(false);
4659
+ const [playbackRate, setPlaybackRate] = useState8(1);
4658
4660
  const audioRef = useRef6(null);
4659
4661
  const formatTime2 = (time) => {
4660
4662
  const minutes = Math.floor(time / 60);
@@ -4708,6 +4710,16 @@ var CardAudio = forwardRef12(
4708
4710
  const toggleVolumeControl = () => {
4709
4711
  setShowVolumeControl(!showVolumeControl);
4710
4712
  };
4713
+ const toggleSpeedMenu = () => {
4714
+ setShowSpeedMenu(!showSpeedMenu);
4715
+ };
4716
+ const handleSpeedChange = (speed) => {
4717
+ setPlaybackRate(speed);
4718
+ if (audioRef.current) {
4719
+ audioRef.current.playbackRate = speed;
4720
+ }
4721
+ setShowSpeedMenu(false);
4722
+ };
4711
4723
  const getVolumeIcon = () => {
4712
4724
  if (volume === 0) {
4713
4725
  return /* @__PURE__ */ jsx26(SpeakerSimpleX, {});
@@ -4864,13 +4876,35 @@ var CardAudio = forwardRef12(
4864
4876
  }
4865
4877
  )
4866
4878
  ] }),
4867
- /* @__PURE__ */ jsx26(
4868
- DotsThreeVertical,
4869
- {
4870
- size: 24,
4871
- className: "text-text-950 cursor-pointer hover:text-primary-600"
4872
- }
4873
- )
4879
+ /* @__PURE__ */ jsxs20("div", { className: "relative", children: [
4880
+ /* @__PURE__ */ jsx26(
4881
+ "button",
4882
+ {
4883
+ type: "button",
4884
+ onClick: toggleSpeedMenu,
4885
+ className: "cursor-pointer text-text-950 hover:text-primary-600",
4886
+ "aria-label": "Op\xE7\xF5es de velocidade",
4887
+ children: /* @__PURE__ */ jsx26(DotsThreeVertical, { size: 24 })
4888
+ }
4889
+ ),
4890
+ showSpeedMenu && /* @__PURE__ */ jsx26("div", { className: "absolute bottom-full right-0 mb-2 p-2 bg-background border border-border-100 rounded-lg shadow-lg min-w-24 z-10", children: /* @__PURE__ */ jsx26("div", { className: "flex flex-col gap-1", children: [
4891
+ { speed: 1, label: "1x" },
4892
+ { speed: 1.5, label: "1.5x" },
4893
+ { speed: 2, label: "2x" }
4894
+ ].map(({ speed, label }) => /* @__PURE__ */ jsx26(
4895
+ "button",
4896
+ {
4897
+ type: "button",
4898
+ onClick: () => handleSpeedChange(speed),
4899
+ className: cn(
4900
+ "px-3 py-1 text-sm text-left rounded hover:bg-border-50 transition-colors",
4901
+ playbackRate === speed ? "bg-primary-950 text-secondary-100 font-medium" : "text-text-950"
4902
+ ),
4903
+ children: label
4904
+ },
4905
+ speed
4906
+ )) }) })
4907
+ ] })
4874
4908
  ]
4875
4909
  }
4876
4910
  );
@@ -6791,6 +6825,7 @@ import {
6791
6825
  import { jsx as jsx36, jsxs as jsxs30 } from "react/jsx-runtime";
6792
6826
  var CONTROLS_HIDE_TIMEOUT = 3e3;
6793
6827
  var LEAVE_HIDE_TIMEOUT = 1e3;
6828
+ var INIT_DELAY = 100;
6794
6829
  var formatTime = (seconds) => {
6795
6830
  if (!seconds || isNaN(seconds)) return "0:00";
6796
6831
  const mins = Math.floor(seconds / 60);
@@ -6909,14 +6944,20 @@ var VideoPlayer = ({
6909
6944
  const trackRef = useRef9(null);
6910
6945
  const controlsTimeoutRef = useRef9(null);
6911
6946
  const lastMousePositionRef = useRef9({ x: 0, y: 0 });
6912
- const mouseMoveTimeoutRef = useRef9(null);
6913
6947
  const isUserInteracting = useCallback(() => {
6914
- if (showSpeedMenu) return true;
6948
+ if (showSpeedMenu) {
6949
+ return true;
6950
+ }
6915
6951
  const activeElement = document.activeElement;
6916
6952
  const videoContainer = videoRef.current?.parentElement;
6917
6953
  if (activeElement && videoContainer?.contains(activeElement)) {
6954
+ if (activeElement === videoRef.current) {
6955
+ return false;
6956
+ }
6918
6957
  const isControl = activeElement.matches("button, input, [tabindex]");
6919
- if (isControl) return true;
6958
+ if (isControl) {
6959
+ return true;
6960
+ }
6920
6961
  }
6921
6962
  return false;
6922
6963
  }, [showSpeedMenu]);
@@ -6926,21 +6967,21 @@ var VideoPlayer = ({
6926
6967
  controlsTimeoutRef.current = null;
6927
6968
  }
6928
6969
  }, []);
6929
- const clearMouseMoveTimeout = useCallback(() => {
6930
- if (mouseMoveTimeoutRef.current) {
6931
- clearTimeout(mouseMoveTimeoutRef.current);
6932
- mouseMoveTimeoutRef.current = null;
6933
- }
6934
- }, []);
6935
6970
  const showControlsWithTimer = useCallback(() => {
6936
6971
  setShowControls(true);
6937
6972
  clearControlsTimeout();
6938
- if (isPlaying) {
6973
+ if (isFullscreen) {
6974
+ if (isPlaying) {
6975
+ controlsTimeoutRef.current = window.setTimeout(() => {
6976
+ setShowControls(false);
6977
+ }, CONTROLS_HIDE_TIMEOUT);
6978
+ }
6979
+ } else {
6939
6980
  controlsTimeoutRef.current = window.setTimeout(() => {
6940
6981
  setShowControls(false);
6941
6982
  }, CONTROLS_HIDE_TIMEOUT);
6942
6983
  }
6943
- }, [isPlaying, clearControlsTimeout]);
6984
+ }, [isFullscreen, isPlaying, clearControlsTimeout]);
6944
6985
  const handleMouseMove = useCallback(
6945
6986
  (event) => {
6946
6987
  const currentX = event.clientX;
@@ -6954,14 +6995,18 @@ var VideoPlayer = ({
6954
6995
  },
6955
6996
  [showControlsWithTimer]
6956
6997
  );
6998
+ const handleMouseEnter = useCallback(() => {
6999
+ showControlsWithTimer();
7000
+ }, [showControlsWithTimer]);
6957
7001
  const handleMouseLeave = useCallback(() => {
7002
+ const userInteracting = isUserInteracting();
6958
7003
  clearControlsTimeout();
6959
- if (isPlaying && !isUserInteracting()) {
7004
+ if (!isFullscreen && !userInteracting) {
6960
7005
  controlsTimeoutRef.current = window.setTimeout(() => {
6961
7006
  setShowControls(false);
6962
7007
  }, LEAVE_HIDE_TIMEOUT);
6963
7008
  }
6964
- }, [isPlaying, clearControlsTimeout, isUserInteracting]);
7009
+ }, [isFullscreen, clearControlsTimeout, isUserInteracting]);
6965
7010
  useEffect11(() => {
6966
7011
  if (videoRef.current) {
6967
7012
  videoRef.current.volume = volume;
@@ -6988,9 +7033,13 @@ var VideoPlayer = ({
6988
7033
  showControlsWithTimer();
6989
7034
  } else {
6990
7035
  clearControlsTimeout();
6991
- setShowControls(true);
7036
+ if (isFullscreen) {
7037
+ setShowControls(true);
7038
+ } else {
7039
+ showControlsWithTimer();
7040
+ }
6992
7041
  }
6993
- }, [isPlaying, showControlsWithTimer, clearControlsTimeout]);
7042
+ }, [isPlaying, isFullscreen, showControlsWithTimer, clearControlsTimeout]);
6994
7043
  useEffect11(() => {
6995
7044
  const handleFullscreenChange = () => {
6996
7045
  const isCurrentlyFullscreen = !!document.fullscreenElement;
@@ -7004,6 +7053,28 @@ var VideoPlayer = ({
7004
7053
  document.removeEventListener("fullscreenchange", handleFullscreenChange);
7005
7054
  };
7006
7055
  }, [showControlsWithTimer]);
7056
+ useEffect11(() => {
7057
+ const init = () => {
7058
+ if (!isFullscreen) {
7059
+ showControlsWithTimer();
7060
+ }
7061
+ };
7062
+ let raf1 = 0, raf2 = 0, tid;
7063
+ if (typeof window.requestAnimationFrame === "function") {
7064
+ raf1 = requestAnimationFrame(() => {
7065
+ raf2 = requestAnimationFrame(init);
7066
+ });
7067
+ return () => {
7068
+ cancelAnimationFrame(raf1);
7069
+ cancelAnimationFrame(raf2);
7070
+ };
7071
+ } else {
7072
+ tid = window.setTimeout(init, INIT_DELAY);
7073
+ return () => {
7074
+ if (tid) clearTimeout(tid);
7075
+ };
7076
+ }
7077
+ }, []);
7007
7078
  const getInitialTime = useCallback(() => {
7008
7079
  if (!autoSave || !storageKey) {
7009
7080
  return Number.isFinite(initialTime) && initialTime >= 0 ? initialTime : void 0;
@@ -7160,22 +7231,15 @@ var VideoPlayer = ({
7160
7231
  document.removeEventListener("visibilitychange", handleVisibilityChange);
7161
7232
  window.removeEventListener("blur", handleBlur);
7162
7233
  clearControlsTimeout();
7163
- clearMouseMoveTimeout();
7164
7234
  };
7165
- }, [isPlaying, clearControlsTimeout, clearMouseMoveTimeout]);
7235
+ }, [isPlaying, clearControlsTimeout]);
7166
7236
  const progressPercentage = duration > 0 ? currentTime / duration * 100 : 0;
7167
7237
  const getTopControlsOpacity = useCallback(() => {
7168
- if (isFullscreen) {
7169
- return showControls ? "opacity-100" : "opacity-0";
7170
- }
7171
- return !isPlaying || showControls ? "opacity-100" : "opacity-0 group-hover:opacity-100";
7172
- }, [isFullscreen, showControls, isPlaying]);
7238
+ return showControls ? "opacity-100" : "opacity-0";
7239
+ }, [showControls]);
7173
7240
  const getBottomControlsOpacity = useCallback(() => {
7174
- if (isFullscreen) {
7175
- return showControls ? "opacity-100" : "opacity-0";
7176
- }
7177
- return !isPlaying || showControls ? "opacity-100" : "opacity-0 group-hover:opacity-100";
7178
- }, [isFullscreen, showControls, isPlaying]);
7241
+ return showControls ? "opacity-100" : "opacity-0";
7242
+ }, [showControls]);
7179
7243
  const handleVideoKeyDown = useCallback(
7180
7244
  (e) => {
7181
7245
  if (e.key) {
@@ -7232,7 +7296,7 @@ var VideoPlayer = ({
7232
7296
  ]
7233
7297
  );
7234
7298
  return /* @__PURE__ */ jsxs30("div", { className: cn("flex flex-col", className), children: [
7235
- (title || subtitleText) && /* @__PURE__ */ jsx36("div", { className: "bg-subject-1 rounded-t-xl px-8 py-4 flex items-end justify-between min-h-20", children: /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", children: [
7299
+ (title || subtitleText) && /* @__PURE__ */ jsx36("div", { className: "bg-subject-1 px-8 py-4 flex items-end justify-between min-h-20", children: /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-1", children: [
7236
7300
  title && /* @__PURE__ */ jsx36(
7237
7301
  Text_default,
7238
7302
  {
@@ -7261,13 +7325,14 @@ var VideoPlayer = ({
7261
7325
  {
7262
7326
  className: cn(
7263
7327
  "relative w-full bg-background overflow-hidden group",
7264
- title || subtitleText ? "rounded-b-xl" : "rounded-xl",
7328
+ "rounded-b-xl",
7265
7329
  // Hide cursor when controls are hidden and video is playing
7266
7330
  isPlaying && !showControls ? "cursor-none group-hover:cursor-default" : "cursor-default"
7267
7331
  ),
7268
7332
  "aria-label": title ? `Video player: ${title}` : "Video player",
7269
7333
  onMouseMove: handleMouseMove,
7270
- onMouseEnter: showControlsWithTimer,
7334
+ onMouseEnter: handleMouseEnter,
7335
+ onTouchStart: handleMouseEnter,
7271
7336
  onMouseLeave: handleMouseLeave,
7272
7337
  children: [
7273
7338
  /* @__PURE__ */ jsx36(