analytica-frontend-lib 1.1.12 → 1.1.13

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
@@ -6791,6 +6791,7 @@ import {
6791
6791
  import { jsx as jsx36, jsxs as jsxs30 } from "react/jsx-runtime";
6792
6792
  var CONTROLS_HIDE_TIMEOUT = 3e3;
6793
6793
  var LEAVE_HIDE_TIMEOUT = 1e3;
6794
+ var INIT_DELAY = 100;
6794
6795
  var formatTime = (seconds) => {
6795
6796
  if (!seconds || isNaN(seconds)) return "0:00";
6796
6797
  const mins = Math.floor(seconds / 60);
@@ -6909,14 +6910,20 @@ var VideoPlayer = ({
6909
6910
  const trackRef = useRef9(null);
6910
6911
  const controlsTimeoutRef = useRef9(null);
6911
6912
  const lastMousePositionRef = useRef9({ x: 0, y: 0 });
6912
- const mouseMoveTimeoutRef = useRef9(null);
6913
6913
  const isUserInteracting = useCallback(() => {
6914
- if (showSpeedMenu) return true;
6914
+ if (showSpeedMenu) {
6915
+ return true;
6916
+ }
6915
6917
  const activeElement = document.activeElement;
6916
6918
  const videoContainer = videoRef.current?.parentElement;
6917
6919
  if (activeElement && videoContainer?.contains(activeElement)) {
6920
+ if (activeElement === videoRef.current) {
6921
+ return false;
6922
+ }
6918
6923
  const isControl = activeElement.matches("button, input, [tabindex]");
6919
- if (isControl) return true;
6924
+ if (isControl) {
6925
+ return true;
6926
+ }
6920
6927
  }
6921
6928
  return false;
6922
6929
  }, [showSpeedMenu]);
@@ -6926,21 +6933,21 @@ var VideoPlayer = ({
6926
6933
  controlsTimeoutRef.current = null;
6927
6934
  }
6928
6935
  }, []);
6929
- const clearMouseMoveTimeout = useCallback(() => {
6930
- if (mouseMoveTimeoutRef.current) {
6931
- clearTimeout(mouseMoveTimeoutRef.current);
6932
- mouseMoveTimeoutRef.current = null;
6933
- }
6934
- }, []);
6935
6936
  const showControlsWithTimer = useCallback(() => {
6936
6937
  setShowControls(true);
6937
6938
  clearControlsTimeout();
6938
- if (isPlaying) {
6939
+ if (isFullscreen) {
6940
+ if (isPlaying) {
6941
+ controlsTimeoutRef.current = window.setTimeout(() => {
6942
+ setShowControls(false);
6943
+ }, CONTROLS_HIDE_TIMEOUT);
6944
+ }
6945
+ } else {
6939
6946
  controlsTimeoutRef.current = window.setTimeout(() => {
6940
6947
  setShowControls(false);
6941
6948
  }, CONTROLS_HIDE_TIMEOUT);
6942
6949
  }
6943
- }, [isPlaying, clearControlsTimeout]);
6950
+ }, [isFullscreen, isPlaying, clearControlsTimeout]);
6944
6951
  const handleMouseMove = useCallback(
6945
6952
  (event) => {
6946
6953
  const currentX = event.clientX;
@@ -6954,14 +6961,18 @@ var VideoPlayer = ({
6954
6961
  },
6955
6962
  [showControlsWithTimer]
6956
6963
  );
6964
+ const handleMouseEnter = useCallback(() => {
6965
+ showControlsWithTimer();
6966
+ }, [showControlsWithTimer]);
6957
6967
  const handleMouseLeave = useCallback(() => {
6968
+ const userInteracting = isUserInteracting();
6958
6969
  clearControlsTimeout();
6959
- if (isPlaying && !isUserInteracting()) {
6970
+ if (!isFullscreen && !userInteracting) {
6960
6971
  controlsTimeoutRef.current = window.setTimeout(() => {
6961
6972
  setShowControls(false);
6962
6973
  }, LEAVE_HIDE_TIMEOUT);
6963
6974
  }
6964
- }, [isPlaying, clearControlsTimeout, isUserInteracting]);
6975
+ }, [isFullscreen, clearControlsTimeout, isUserInteracting]);
6965
6976
  useEffect11(() => {
6966
6977
  if (videoRef.current) {
6967
6978
  videoRef.current.volume = volume;
@@ -6988,9 +6999,13 @@ var VideoPlayer = ({
6988
6999
  showControlsWithTimer();
6989
7000
  } else {
6990
7001
  clearControlsTimeout();
6991
- setShowControls(true);
7002
+ if (isFullscreen) {
7003
+ setShowControls(true);
7004
+ } else {
7005
+ showControlsWithTimer();
7006
+ }
6992
7007
  }
6993
- }, [isPlaying, showControlsWithTimer, clearControlsTimeout]);
7008
+ }, [isPlaying, isFullscreen, showControlsWithTimer, clearControlsTimeout]);
6994
7009
  useEffect11(() => {
6995
7010
  const handleFullscreenChange = () => {
6996
7011
  const isCurrentlyFullscreen = !!document.fullscreenElement;
@@ -7004,6 +7019,28 @@ var VideoPlayer = ({
7004
7019
  document.removeEventListener("fullscreenchange", handleFullscreenChange);
7005
7020
  };
7006
7021
  }, [showControlsWithTimer]);
7022
+ useEffect11(() => {
7023
+ const init = () => {
7024
+ if (!isFullscreen) {
7025
+ showControlsWithTimer();
7026
+ }
7027
+ };
7028
+ let raf1 = 0, raf2 = 0, tid;
7029
+ if (typeof window.requestAnimationFrame === "function") {
7030
+ raf1 = requestAnimationFrame(() => {
7031
+ raf2 = requestAnimationFrame(init);
7032
+ });
7033
+ return () => {
7034
+ cancelAnimationFrame(raf1);
7035
+ cancelAnimationFrame(raf2);
7036
+ };
7037
+ } else {
7038
+ tid = window.setTimeout(init, INIT_DELAY);
7039
+ return () => {
7040
+ if (tid) clearTimeout(tid);
7041
+ };
7042
+ }
7043
+ }, []);
7007
7044
  const getInitialTime = useCallback(() => {
7008
7045
  if (!autoSave || !storageKey) {
7009
7046
  return Number.isFinite(initialTime) && initialTime >= 0 ? initialTime : void 0;
@@ -7160,22 +7197,15 @@ var VideoPlayer = ({
7160
7197
  document.removeEventListener("visibilitychange", handleVisibilityChange);
7161
7198
  window.removeEventListener("blur", handleBlur);
7162
7199
  clearControlsTimeout();
7163
- clearMouseMoveTimeout();
7164
7200
  };
7165
- }, [isPlaying, clearControlsTimeout, clearMouseMoveTimeout]);
7201
+ }, [isPlaying, clearControlsTimeout]);
7166
7202
  const progressPercentage = duration > 0 ? currentTime / duration * 100 : 0;
7167
7203
  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]);
7204
+ return showControls ? "opacity-100" : "opacity-0";
7205
+ }, [showControls]);
7173
7206
  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]);
7207
+ return showControls ? "opacity-100" : "opacity-0";
7208
+ }, [showControls]);
7179
7209
  const handleVideoKeyDown = useCallback(
7180
7210
  (e) => {
7181
7211
  if (e.key) {
@@ -7232,7 +7262,7 @@ var VideoPlayer = ({
7232
7262
  ]
7233
7263
  );
7234
7264
  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: [
7265
+ (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
7266
  title && /* @__PURE__ */ jsx36(
7237
7267
  Text_default,
7238
7268
  {
@@ -7261,13 +7291,14 @@ var VideoPlayer = ({
7261
7291
  {
7262
7292
  className: cn(
7263
7293
  "relative w-full bg-background overflow-hidden group",
7264
- title || subtitleText ? "rounded-b-xl" : "rounded-xl",
7294
+ "rounded-b-xl",
7265
7295
  // Hide cursor when controls are hidden and video is playing
7266
7296
  isPlaying && !showControls ? "cursor-none group-hover:cursor-default" : "cursor-default"
7267
7297
  ),
7268
7298
  "aria-label": title ? `Video player: ${title}` : "Video player",
7269
7299
  onMouseMove: handleMouseMove,
7270
- onMouseEnter: showControlsWithTimer,
7300
+ onMouseEnter: handleMouseEnter,
7301
+ onTouchStart: handleMouseEnter,
7271
7302
  onMouseLeave: handleMouseLeave,
7272
7303
  children: [
7273
7304
  /* @__PURE__ */ jsx36(