analytica-frontend-lib 1.1.11 → 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/VideoPlayer/index.js +82 -31
- package/dist/VideoPlayer/index.js.map +1 -1
- package/dist/VideoPlayer/index.mjs +82 -31
- package/dist/VideoPlayer/index.mjs.map +1 -1
- package/dist/index.css +7 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +82 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -31
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +7 -0
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6826,6 +6826,9 @@ var NotFound_default = NotFound;
|
|
|
6826
6826
|
var import_react22 = require("react");
|
|
6827
6827
|
var import_phosphor_react18 = require("phosphor-react");
|
|
6828
6828
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
6829
|
+
var CONTROLS_HIDE_TIMEOUT = 3e3;
|
|
6830
|
+
var LEAVE_HIDE_TIMEOUT = 1e3;
|
|
6831
|
+
var INIT_DELAY = 100;
|
|
6829
6832
|
var formatTime = (seconds) => {
|
|
6830
6833
|
if (!seconds || isNaN(seconds)) return "0:00";
|
|
6831
6834
|
const mins = Math.floor(seconds / 60);
|
|
@@ -6944,29 +6947,44 @@ var VideoPlayer = ({
|
|
|
6944
6947
|
const trackRef = (0, import_react22.useRef)(null);
|
|
6945
6948
|
const controlsTimeoutRef = (0, import_react22.useRef)(null);
|
|
6946
6949
|
const lastMousePositionRef = (0, import_react22.useRef)({ x: 0, y: 0 });
|
|
6947
|
-
const
|
|
6950
|
+
const isUserInteracting = (0, import_react22.useCallback)(() => {
|
|
6951
|
+
if (showSpeedMenu) {
|
|
6952
|
+
return true;
|
|
6953
|
+
}
|
|
6954
|
+
const activeElement = document.activeElement;
|
|
6955
|
+
const videoContainer = videoRef.current?.parentElement;
|
|
6956
|
+
if (activeElement && videoContainer?.contains(activeElement)) {
|
|
6957
|
+
if (activeElement === videoRef.current) {
|
|
6958
|
+
return false;
|
|
6959
|
+
}
|
|
6960
|
+
const isControl = activeElement.matches("button, input, [tabindex]");
|
|
6961
|
+
if (isControl) {
|
|
6962
|
+
return true;
|
|
6963
|
+
}
|
|
6964
|
+
}
|
|
6965
|
+
return false;
|
|
6966
|
+
}, [showSpeedMenu]);
|
|
6948
6967
|
const clearControlsTimeout = (0, import_react22.useCallback)(() => {
|
|
6949
6968
|
if (controlsTimeoutRef.current) {
|
|
6950
6969
|
clearTimeout(controlsTimeoutRef.current);
|
|
6951
6970
|
controlsTimeoutRef.current = null;
|
|
6952
6971
|
}
|
|
6953
6972
|
}, []);
|
|
6954
|
-
const clearMouseMoveTimeout = (0, import_react22.useCallback)(() => {
|
|
6955
|
-
if (mouseMoveTimeoutRef.current) {
|
|
6956
|
-
clearTimeout(mouseMoveTimeoutRef.current);
|
|
6957
|
-
mouseMoveTimeoutRef.current = null;
|
|
6958
|
-
}
|
|
6959
|
-
}, []);
|
|
6960
6973
|
const showControlsWithTimer = (0, import_react22.useCallback)(() => {
|
|
6961
6974
|
setShowControls(true);
|
|
6962
6975
|
clearControlsTimeout();
|
|
6963
|
-
if (
|
|
6964
|
-
|
|
6976
|
+
if (isFullscreen) {
|
|
6977
|
+
if (isPlaying) {
|
|
6978
|
+
controlsTimeoutRef.current = window.setTimeout(() => {
|
|
6979
|
+
setShowControls(false);
|
|
6980
|
+
}, CONTROLS_HIDE_TIMEOUT);
|
|
6981
|
+
}
|
|
6982
|
+
} else {
|
|
6965
6983
|
controlsTimeoutRef.current = window.setTimeout(() => {
|
|
6966
6984
|
setShowControls(false);
|
|
6967
|
-
},
|
|
6985
|
+
}, CONTROLS_HIDE_TIMEOUT);
|
|
6968
6986
|
}
|
|
6969
|
-
}, [
|
|
6987
|
+
}, [isFullscreen, isPlaying, clearControlsTimeout]);
|
|
6970
6988
|
const handleMouseMove = (0, import_react22.useCallback)(
|
|
6971
6989
|
(event) => {
|
|
6972
6990
|
const currentX = event.clientX;
|
|
@@ -6980,6 +6998,18 @@ var VideoPlayer = ({
|
|
|
6980
6998
|
},
|
|
6981
6999
|
[showControlsWithTimer]
|
|
6982
7000
|
);
|
|
7001
|
+
const handleMouseEnter = (0, import_react22.useCallback)(() => {
|
|
7002
|
+
showControlsWithTimer();
|
|
7003
|
+
}, [showControlsWithTimer]);
|
|
7004
|
+
const handleMouseLeave = (0, import_react22.useCallback)(() => {
|
|
7005
|
+
const userInteracting = isUserInteracting();
|
|
7006
|
+
clearControlsTimeout();
|
|
7007
|
+
if (!isFullscreen && !userInteracting) {
|
|
7008
|
+
controlsTimeoutRef.current = window.setTimeout(() => {
|
|
7009
|
+
setShowControls(false);
|
|
7010
|
+
}, LEAVE_HIDE_TIMEOUT);
|
|
7011
|
+
}
|
|
7012
|
+
}, [isFullscreen, clearControlsTimeout, isUserInteracting]);
|
|
6983
7013
|
(0, import_react22.useEffect)(() => {
|
|
6984
7014
|
if (videoRef.current) {
|
|
6985
7015
|
videoRef.current.volume = volume;
|
|
@@ -7006,9 +7036,13 @@ var VideoPlayer = ({
|
|
|
7006
7036
|
showControlsWithTimer();
|
|
7007
7037
|
} else {
|
|
7008
7038
|
clearControlsTimeout();
|
|
7009
|
-
|
|
7039
|
+
if (isFullscreen) {
|
|
7040
|
+
setShowControls(true);
|
|
7041
|
+
} else {
|
|
7042
|
+
showControlsWithTimer();
|
|
7043
|
+
}
|
|
7010
7044
|
}
|
|
7011
|
-
}, [isPlaying, showControlsWithTimer, clearControlsTimeout]);
|
|
7045
|
+
}, [isPlaying, isFullscreen, showControlsWithTimer, clearControlsTimeout]);
|
|
7012
7046
|
(0, import_react22.useEffect)(() => {
|
|
7013
7047
|
const handleFullscreenChange = () => {
|
|
7014
7048
|
const isCurrentlyFullscreen = !!document.fullscreenElement;
|
|
@@ -7022,6 +7056,28 @@ var VideoPlayer = ({
|
|
|
7022
7056
|
document.removeEventListener("fullscreenchange", handleFullscreenChange);
|
|
7023
7057
|
};
|
|
7024
7058
|
}, [showControlsWithTimer]);
|
|
7059
|
+
(0, import_react22.useEffect)(() => {
|
|
7060
|
+
const init = () => {
|
|
7061
|
+
if (!isFullscreen) {
|
|
7062
|
+
showControlsWithTimer();
|
|
7063
|
+
}
|
|
7064
|
+
};
|
|
7065
|
+
let raf1 = 0, raf2 = 0, tid;
|
|
7066
|
+
if (typeof window.requestAnimationFrame === "function") {
|
|
7067
|
+
raf1 = requestAnimationFrame(() => {
|
|
7068
|
+
raf2 = requestAnimationFrame(init);
|
|
7069
|
+
});
|
|
7070
|
+
return () => {
|
|
7071
|
+
cancelAnimationFrame(raf1);
|
|
7072
|
+
cancelAnimationFrame(raf2);
|
|
7073
|
+
};
|
|
7074
|
+
} else {
|
|
7075
|
+
tid = window.setTimeout(init, INIT_DELAY);
|
|
7076
|
+
return () => {
|
|
7077
|
+
if (tid) clearTimeout(tid);
|
|
7078
|
+
};
|
|
7079
|
+
}
|
|
7080
|
+
}, []);
|
|
7025
7081
|
const getInitialTime = (0, import_react22.useCallback)(() => {
|
|
7026
7082
|
if (!autoSave || !storageKey) {
|
|
7027
7083
|
return Number.isFinite(initialTime) && initialTime >= 0 ? initialTime : void 0;
|
|
@@ -7178,22 +7234,15 @@ var VideoPlayer = ({
|
|
|
7178
7234
|
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
7179
7235
|
window.removeEventListener("blur", handleBlur);
|
|
7180
7236
|
clearControlsTimeout();
|
|
7181
|
-
clearMouseMoveTimeout();
|
|
7182
7237
|
};
|
|
7183
|
-
}, [isPlaying, clearControlsTimeout
|
|
7238
|
+
}, [isPlaying, clearControlsTimeout]);
|
|
7184
7239
|
const progressPercentage = duration > 0 ? currentTime / duration * 100 : 0;
|
|
7185
7240
|
const getTopControlsOpacity = (0, import_react22.useCallback)(() => {
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
}
|
|
7189
|
-
return !isPlaying || showControls ? "opacity-100" : "opacity-0 group-hover:opacity-100";
|
|
7190
|
-
}, [isFullscreen, showControls, isPlaying]);
|
|
7241
|
+
return showControls ? "opacity-100" : "opacity-0";
|
|
7242
|
+
}, [showControls]);
|
|
7191
7243
|
const getBottomControlsOpacity = (0, import_react22.useCallback)(() => {
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
}
|
|
7195
|
-
return !isPlaying || showControls ? "opacity-100" : "opacity-0 group-hover:opacity-100";
|
|
7196
|
-
}, [isFullscreen, showControls, isPlaying]);
|
|
7244
|
+
return showControls ? "opacity-100" : "opacity-0";
|
|
7245
|
+
}, [showControls]);
|
|
7197
7246
|
const handleVideoKeyDown = (0, import_react22.useCallback)(
|
|
7198
7247
|
(e) => {
|
|
7199
7248
|
if (e.key) {
|
|
@@ -7250,7 +7299,7 @@ var VideoPlayer = ({
|
|
|
7250
7299
|
]
|
|
7251
7300
|
);
|
|
7252
7301
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: cn("flex flex-col", className), children: [
|
|
7253
|
-
(title || subtitleText) && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "bg-subject-1
|
|
7302
|
+
(title || subtitleText) && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "bg-subject-1 px-8 py-4 flex items-end justify-between min-h-20", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
7254
7303
|
title && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7255
7304
|
Text_default,
|
|
7256
7305
|
{
|
|
@@ -7279,13 +7328,15 @@ var VideoPlayer = ({
|
|
|
7279
7328
|
{
|
|
7280
7329
|
className: cn(
|
|
7281
7330
|
"relative w-full bg-background overflow-hidden group",
|
|
7282
|
-
|
|
7283
|
-
// Hide cursor when controls are hidden and video is playing
|
|
7284
|
-
|
|
7331
|
+
"rounded-b-xl",
|
|
7332
|
+
// Hide cursor when controls are hidden and video is playing
|
|
7333
|
+
isPlaying && !showControls ? "cursor-none group-hover:cursor-default" : "cursor-default"
|
|
7285
7334
|
),
|
|
7286
7335
|
"aria-label": title ? `Video player: ${title}` : "Video player",
|
|
7287
|
-
onMouseMove:
|
|
7288
|
-
onMouseEnter:
|
|
7336
|
+
onMouseMove: handleMouseMove,
|
|
7337
|
+
onMouseEnter: handleMouseEnter,
|
|
7338
|
+
onTouchStart: handleMouseEnter,
|
|
7339
|
+
onMouseLeave: handleMouseLeave,
|
|
7289
7340
|
children: [
|
|
7290
7341
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7291
7342
|
"video",
|