analytica-frontend-lib 1.1.77 → 1.1.78

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
@@ -6697,6 +6697,10 @@ var getSubjectName = (subject) => {
6697
6697
  import { useState as useState13, useEffect as useEffect12 } from "react";
6698
6698
  var MOBILE_WIDTH = 500;
6699
6699
  var TABLET_WIDTH = 931;
6700
+ var SMALL_MOBILE_WIDTH = 425;
6701
+ var EXTRA_SMALL_MOBILE_WIDTH = 375;
6702
+ var ULTRA_SMALL_MOBILE_WIDTH = 375;
6703
+ var TINY_MOBILE_WIDTH = 320;
6700
6704
  var DEFAULT_WIDTH = 1200;
6701
6705
  var getWindowWidth = () => {
6702
6706
  if (typeof window === "undefined") {
@@ -6711,11 +6715,19 @@ var getDeviceType = () => {
6711
6715
  var useMobile = () => {
6712
6716
  const [isMobile, setIsMobile] = useState13(false);
6713
6717
  const [isTablet, setIsTablet] = useState13(false);
6718
+ const [isSmallMobile, setIsSmallMobile] = useState13(false);
6719
+ const [isExtraSmallMobile, setIsExtraSmallMobile] = useState13(false);
6720
+ const [isUltraSmallMobile, setIsUltraSmallMobile] = useState13(false);
6721
+ const [isTinyMobile, setIsTinyMobile] = useState13(false);
6714
6722
  useEffect12(() => {
6715
6723
  const checkScreenSize = () => {
6716
6724
  const width = getWindowWidth();
6717
6725
  setIsMobile(width < MOBILE_WIDTH);
6718
6726
  setIsTablet(width < TABLET_WIDTH);
6727
+ setIsSmallMobile(width < SMALL_MOBILE_WIDTH);
6728
+ setIsExtraSmallMobile(width < EXTRA_SMALL_MOBILE_WIDTH);
6729
+ setIsUltraSmallMobile(width < ULTRA_SMALL_MOBILE_WIDTH);
6730
+ setIsTinyMobile(width < TINY_MOBILE_WIDTH);
6719
6731
  };
6720
6732
  checkScreenSize();
6721
6733
  window.addEventListener("resize", checkScreenSize);
@@ -6739,13 +6751,24 @@ var useMobile = () => {
6739
6751
  const getHeaderClasses = () => {
6740
6752
  return isMobile ? getMobileHeaderClasses() : getDesktopHeaderClasses();
6741
6753
  };
6754
+ const getVideoContainerClasses = () => {
6755
+ if (isTinyMobile) return "aspect-square";
6756
+ if (isExtraSmallMobile) return "aspect-[4/3]";
6757
+ if (isSmallMobile) return "aspect-[16/12]";
6758
+ return "aspect-video";
6759
+ };
6742
6760
  return {
6743
6761
  isMobile,
6744
6762
  isTablet,
6763
+ isSmallMobile,
6764
+ isExtraSmallMobile,
6765
+ isUltraSmallMobile,
6766
+ isTinyMobile,
6745
6767
  getFormContainerClasses,
6746
6768
  getHeaderClasses,
6747
6769
  getMobileHeaderClasses,
6748
6770
  getDesktopHeaderClasses,
6771
+ getVideoContainerClasses,
6749
6772
  getDeviceType
6750
6773
  };
6751
6774
  };
@@ -7708,8 +7731,9 @@ var ProgressBar2 = ({
7708
7731
  currentTime,
7709
7732
  duration,
7710
7733
  progressPercentage,
7711
- onSeek
7712
- }) => /* @__PURE__ */ jsx44("div", { className: "px-4 pb-2", children: /* @__PURE__ */ jsx44(
7734
+ onSeek,
7735
+ className = "px-4 pb-2"
7736
+ }) => /* @__PURE__ */ jsx44("div", { className, children: /* @__PURE__ */ jsx44(
7713
7737
  "input",
7714
7738
  {
7715
7739
  type: "range",
@@ -7728,18 +7752,20 @@ var VolumeControls = ({
7728
7752
  volume,
7729
7753
  isMuted,
7730
7754
  onVolumeChange,
7731
- onToggleMute
7755
+ onToggleMute,
7756
+ iconSize = 24,
7757
+ showSlider = true
7732
7758
  }) => /* @__PURE__ */ jsxs32("div", { className: "flex items-center gap-2", children: [
7733
7759
  /* @__PURE__ */ jsx44(
7734
7760
  IconButton_default,
7735
7761
  {
7736
- icon: isMuted ? /* @__PURE__ */ jsx44(SpeakerSlash, { size: 24 }) : /* @__PURE__ */ jsx44(SpeakerHigh2, { size: 24 }),
7762
+ icon: isMuted ? /* @__PURE__ */ jsx44(SpeakerSlash, { size: iconSize }) : /* @__PURE__ */ jsx44(SpeakerHigh2, { size: iconSize }),
7737
7763
  onClick: onToggleMute,
7738
7764
  "aria-label": isMuted ? "Unmute" : "Mute",
7739
7765
  className: "!bg-transparent !text-white hover:!bg-white/20"
7740
7766
  }
7741
7767
  ),
7742
- /* @__PURE__ */ jsx44(
7768
+ showSlider && /* @__PURE__ */ jsx44(
7743
7769
  "input",
7744
7770
  {
7745
7771
  type: "range",
@@ -7760,7 +7786,9 @@ var SpeedMenu = ({
7760
7786
  playbackRate,
7761
7787
  onToggleMenu,
7762
7788
  onSpeedChange,
7763
- isFullscreen
7789
+ isFullscreen,
7790
+ iconSize = 24,
7791
+ isTinyMobile = false
7764
7792
  }) => {
7765
7793
  const buttonRef = useRef9(null);
7766
7794
  const speedMenuContainerRef = useRef9(null);
@@ -7768,10 +7796,13 @@ var SpeedMenu = ({
7768
7796
  const getMenuPosition = () => {
7769
7797
  if (!buttonRef.current) return { top: 0, left: 0 };
7770
7798
  const rect = buttonRef.current.getBoundingClientRect();
7799
+ const menuHeight = isTinyMobile ? 150 : 180;
7800
+ const menuWidth = isTinyMobile ? 60 : 80;
7801
+ const padding = isTinyMobile ? 4 : 8;
7771
7802
  return {
7772
7803
  // Fixed coords are viewport-based — no scroll offsets.
7773
- top: Math.max(8, rect.top - 180),
7774
- left: Math.max(8, rect.right - 80)
7804
+ top: Math.max(padding, rect.top - menuHeight),
7805
+ left: Math.max(padding, rect.right - menuWidth)
7775
7806
  };
7776
7807
  };
7777
7808
  const position = getMenuPosition();
@@ -7824,7 +7855,7 @@ var SpeedMenu = ({
7824
7855
  IconButton_default,
7825
7856
  {
7826
7857
  ref: buttonRef,
7827
- icon: /* @__PURE__ */ jsx44(DotsThreeVertical2, { size: 24 }),
7858
+ icon: /* @__PURE__ */ jsx44(DotsThreeVertical2, { size: iconSize }),
7828
7859
  onClick: onToggleMenu,
7829
7860
  "aria-label": "Playback speed",
7830
7861
  "aria-haspopup": "menu",
@@ -7850,6 +7881,7 @@ var VideoPlayer = ({
7850
7881
  storageKey = "video-progress"
7851
7882
  }) => {
7852
7883
  const videoRef = useRef9(null);
7884
+ const { isUltraSmallMobile, isTinyMobile } = useMobile();
7853
7885
  const [isPlaying, setIsPlaying] = useState15(false);
7854
7886
  const [currentTime, setCurrentTime] = useState15(0);
7855
7887
  const [duration, setDuration] = useState15(0);
@@ -7952,6 +7984,12 @@ var VideoPlayer = ({
7952
7984
  video.removeEventListener("ended", onEnded);
7953
7985
  };
7954
7986
  }, []);
7987
+ useEffect15(() => {
7988
+ const video = videoRef.current;
7989
+ if (!video) return;
7990
+ video.setAttribute("playsinline", "");
7991
+ video.setAttribute("webkit-playsinline", "");
7992
+ }, []);
7955
7993
  useEffect15(() => {
7956
7994
  if (isPlaying) {
7957
7995
  showControlsWithTimer();
@@ -8158,6 +8196,31 @@ var VideoPlayer = ({
8158
8196
  };
8159
8197
  }, [isPlaying, clearControlsTimeout]);
8160
8198
  const progressPercentage = duration > 0 ? currentTime / duration * 100 : 0;
8199
+ const getIconSize2 = useCallback(() => {
8200
+ if (isTinyMobile) return 18;
8201
+ if (isUltraSmallMobile) return 20;
8202
+ return 24;
8203
+ }, [isTinyMobile, isUltraSmallMobile]);
8204
+ const getControlsPadding = useCallback(() => {
8205
+ if (isTinyMobile) return "px-2 pb-2 pt-1";
8206
+ if (isUltraSmallMobile) return "px-3 pb-3 pt-1";
8207
+ return "px-4 pb-4";
8208
+ }, [isTinyMobile, isUltraSmallMobile]);
8209
+ const getControlsGap = useCallback(() => {
8210
+ if (isTinyMobile) return "gap-1";
8211
+ if (isUltraSmallMobile) return "gap-2";
8212
+ return "gap-4";
8213
+ }, [isTinyMobile, isUltraSmallMobile]);
8214
+ const getProgressBarPadding = useCallback(() => {
8215
+ if (isTinyMobile) return "px-2 pb-1";
8216
+ if (isUltraSmallMobile) return "px-3 pb-1";
8217
+ return "px-4 pb-2";
8218
+ }, [isTinyMobile, isUltraSmallMobile]);
8219
+ const getCenterPlayButtonPosition = useCallback(() => {
8220
+ if (isTinyMobile) return "items-center justify-center -translate-y-12";
8221
+ if (isUltraSmallMobile) return "items-center justify-center -translate-y-8";
8222
+ return "items-center justify-center";
8223
+ }, [isTinyMobile, isUltraSmallMobile]);
8161
8224
  const getTopControlsOpacity = useCallback(() => {
8162
8225
  return showControls ? "opacity-100" : "opacity-0";
8163
8226
  }, [showControls]);
@@ -8265,8 +8328,9 @@ var VideoPlayer = ({
8265
8328
  ref: videoRef,
8266
8329
  src,
8267
8330
  poster,
8268
- className: "w-full h-full object-contain",
8331
+ className: "w-full h-full object-contain analytica-video",
8269
8332
  controlsList: "nodownload",
8333
+ playsInline: true,
8270
8334
  onTimeUpdate: handleTimeUpdate,
8271
8335
  onLoadedMetadata: handleLoadedMetadata,
8272
8336
  onClick: togglePlayPause,
@@ -8286,15 +8350,24 @@ var VideoPlayer = ({
8286
8350
  )
8287
8351
  }
8288
8352
  ),
8289
- !isPlaying && /* @__PURE__ */ jsx44("div", { className: "absolute inset-0 flex items-center justify-center bg-black/30 transition-opacity", children: /* @__PURE__ */ jsx44(
8290
- IconButton_default,
8353
+ !isPlaying && /* @__PURE__ */ jsx44(
8354
+ "div",
8291
8355
  {
8292
- icon: /* @__PURE__ */ jsx44(Play2, { size: 32, weight: "regular", className: "ml-1" }),
8293
- onClick: togglePlayPause,
8294
- "aria-label": "Play video",
8295
- className: "!bg-transparent !text-white !w-auto !h-auto hover:!bg-transparent hover:!text-gray-200"
8356
+ className: cn(
8357
+ "absolute inset-0 flex bg-black/30 transition-opacity",
8358
+ getCenterPlayButtonPosition()
8359
+ ),
8360
+ children: /* @__PURE__ */ jsx44(
8361
+ IconButton_default,
8362
+ {
8363
+ icon: /* @__PURE__ */ jsx44(Play2, { size: 32, weight: "regular", className: "ml-1" }),
8364
+ onClick: togglePlayPause,
8365
+ "aria-label": "Play video",
8366
+ className: "!bg-transparent !text-white !w-auto !h-auto hover:!bg-transparent hover:!text-gray-200"
8367
+ }
8368
+ )
8296
8369
  }
8297
- ) }),
8370
+ ),
8298
8371
  /* @__PURE__ */ jsx44(
8299
8372
  "div",
8300
8373
  {
@@ -8327,58 +8400,72 @@ var VideoPlayer = ({
8327
8400
  currentTime,
8328
8401
  duration,
8329
8402
  progressPercentage,
8330
- onSeek: handleSeek
8403
+ onSeek: handleSeek,
8404
+ className: getProgressBarPadding()
8331
8405
  }
8332
8406
  ),
8333
- /* @__PURE__ */ jsxs32("div", { className: "flex items-center justify-between px-4 pb-4", children: [
8334
- /* @__PURE__ */ jsxs32("div", { className: "flex items-center gap-4", children: [
8335
- /* @__PURE__ */ jsx44(
8336
- IconButton_default,
8337
- {
8338
- icon: isPlaying ? /* @__PURE__ */ jsx44(Pause, { size: 24 }) : /* @__PURE__ */ jsx44(Play2, { size: 24 }),
8339
- onClick: togglePlayPause,
8340
- "aria-label": isPlaying ? "Pause" : "Play",
8341
- className: "!bg-transparent !text-white hover:!bg-white/20"
8342
- }
8343
- ),
8344
- /* @__PURE__ */ jsx44(
8345
- VolumeControls,
8346
- {
8347
- volume,
8348
- isMuted,
8349
- onVolumeChange: handleVolumeChange,
8350
- onToggleMute: toggleMute
8351
- }
8352
- ),
8353
- subtitles && /* @__PURE__ */ jsx44(
8354
- IconButton_default,
8355
- {
8356
- icon: /* @__PURE__ */ jsx44(ClosedCaptioning, { size: 24 }),
8357
- onClick: toggleCaptions,
8358
- "aria-label": showCaptions ? "Hide captions" : "Show captions",
8359
- className: cn(
8360
- "!bg-transparent hover:!bg-white/20",
8361
- showCaptions ? "!text-primary-400" : "!text-white"
8362
- )
8363
- }
8407
+ /* @__PURE__ */ jsxs32(
8408
+ "div",
8409
+ {
8410
+ className: cn(
8411
+ "flex items-center justify-between",
8412
+ getControlsPadding()
8364
8413
  ),
8365
- /* @__PURE__ */ jsxs32(Text_default, { size: "sm", weight: "medium", color: "text-white", children: [
8366
- formatTime(currentTime),
8367
- " / ",
8368
- formatTime(duration)
8369
- ] })
8370
- ] }),
8371
- /* @__PURE__ */ jsx44("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ jsx44(
8372
- SpeedMenu,
8373
- {
8374
- showSpeedMenu,
8375
- playbackRate,
8376
- onToggleMenu: toggleSpeedMenu,
8377
- onSpeedChange: handleSpeedChange,
8378
- isFullscreen
8379
- }
8380
- ) })
8381
- ] })
8414
+ children: [
8415
+ /* @__PURE__ */ jsxs32("div", { className: cn("flex items-center", getControlsGap()), children: [
8416
+ /* @__PURE__ */ jsx44(
8417
+ IconButton_default,
8418
+ {
8419
+ icon: isPlaying ? /* @__PURE__ */ jsx44(Pause, { size: getIconSize2() }) : /* @__PURE__ */ jsx44(Play2, { size: getIconSize2() }),
8420
+ onClick: togglePlayPause,
8421
+ "aria-label": isPlaying ? "Pause" : "Play",
8422
+ className: "!bg-transparent !text-white hover:!bg-white/20"
8423
+ }
8424
+ ),
8425
+ /* @__PURE__ */ jsx44(
8426
+ VolumeControls,
8427
+ {
8428
+ volume,
8429
+ isMuted,
8430
+ onVolumeChange: handleVolumeChange,
8431
+ onToggleMute: toggleMute,
8432
+ iconSize: getIconSize2(),
8433
+ showSlider: !isUltraSmallMobile
8434
+ }
8435
+ ),
8436
+ subtitles && /* @__PURE__ */ jsx44(
8437
+ IconButton_default,
8438
+ {
8439
+ icon: /* @__PURE__ */ jsx44(ClosedCaptioning, { size: getIconSize2() }),
8440
+ onClick: toggleCaptions,
8441
+ "aria-label": showCaptions ? "Hide captions" : "Show captions",
8442
+ className: cn(
8443
+ "!bg-transparent hover:!bg-white/20",
8444
+ showCaptions ? "!text-primary-400" : "!text-white"
8445
+ )
8446
+ }
8447
+ ),
8448
+ /* @__PURE__ */ jsxs32(Text_default, { size: "sm", weight: "medium", color: "text-white", children: [
8449
+ formatTime(currentTime),
8450
+ " / ",
8451
+ formatTime(duration)
8452
+ ] })
8453
+ ] }),
8454
+ /* @__PURE__ */ jsx44("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ jsx44(
8455
+ SpeedMenu,
8456
+ {
8457
+ showSpeedMenu,
8458
+ playbackRate,
8459
+ onToggleMenu: toggleSpeedMenu,
8460
+ onSpeedChange: handleSpeedChange,
8461
+ iconSize: getIconSize2(),
8462
+ isTinyMobile,
8463
+ isFullscreen
8464
+ }
8465
+ ) })
8466
+ ]
8467
+ }
8468
+ )
8382
8469
  ]
8383
8470
  }
8384
8471
  )