analytica-frontend-lib 1.1.77 → 1.1.79

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
@@ -2274,9 +2274,23 @@ var injectStore3 = (children, store) => {
2274
2274
  return Children3.map(children, (child) => {
2275
2275
  if (isValidElement3(child)) {
2276
2276
  const typedChild = child;
2277
- const newProps = {
2278
- store
2279
- };
2277
+ const displayName = typedChild.type.displayName;
2278
+ const allowed = [
2279
+ "DropdownMenuTrigger",
2280
+ "DropdownContent",
2281
+ "DropdownMenuContent",
2282
+ "DropdownMenuSeparator",
2283
+ "DropdownMenuItem",
2284
+ "MenuLabel",
2285
+ "ProfileMenuTrigger",
2286
+ "ProfileMenuHeader",
2287
+ "ProfileMenuFooter",
2288
+ "ProfileToggleTheme"
2289
+ ];
2290
+ let newProps = {};
2291
+ if (allowed.includes(displayName)) {
2292
+ newProps.store = store;
2293
+ }
2280
2294
  if (typedChild.props.children) {
2281
2295
  newProps.children = injectStore3(typedChild.props.children, store);
2282
2296
  }
@@ -2362,13 +2376,22 @@ var DropdownMenuTrigger = ({
2362
2376
  const open = useStore3(store, (s) => s.open);
2363
2377
  const toggleOpen = () => store.setState({ open: !open });
2364
2378
  return /* @__PURE__ */ jsx20(
2365
- "button",
2379
+ "div",
2366
2380
  {
2367
2381
  onClick: (e) => {
2368
2382
  e.stopPropagation();
2369
2383
  toggleOpen();
2370
2384
  if (onClick) onClick(e);
2371
2385
  },
2386
+ role: "button",
2387
+ onKeyDown: (e) => {
2388
+ if (e.key === "Enter" || e.key === " ") {
2389
+ e.preventDefault();
2390
+ toggleOpen();
2391
+ if (onClick) onClick(e);
2392
+ }
2393
+ },
2394
+ tabIndex: 0,
2372
2395
  "aria-expanded": open,
2373
2396
  className: cn(className),
2374
2397
  ...props,
@@ -6697,6 +6720,10 @@ var getSubjectName = (subject) => {
6697
6720
  import { useState as useState13, useEffect as useEffect12 } from "react";
6698
6721
  var MOBILE_WIDTH = 500;
6699
6722
  var TABLET_WIDTH = 931;
6723
+ var SMALL_MOBILE_WIDTH = 425;
6724
+ var EXTRA_SMALL_MOBILE_WIDTH = 375;
6725
+ var ULTRA_SMALL_MOBILE_WIDTH = 375;
6726
+ var TINY_MOBILE_WIDTH = 320;
6700
6727
  var DEFAULT_WIDTH = 1200;
6701
6728
  var getWindowWidth = () => {
6702
6729
  if (typeof window === "undefined") {
@@ -6711,11 +6738,19 @@ var getDeviceType = () => {
6711
6738
  var useMobile = () => {
6712
6739
  const [isMobile, setIsMobile] = useState13(false);
6713
6740
  const [isTablet, setIsTablet] = useState13(false);
6741
+ const [isSmallMobile, setIsSmallMobile] = useState13(false);
6742
+ const [isExtraSmallMobile, setIsExtraSmallMobile] = useState13(false);
6743
+ const [isUltraSmallMobile, setIsUltraSmallMobile] = useState13(false);
6744
+ const [isTinyMobile, setIsTinyMobile] = useState13(false);
6714
6745
  useEffect12(() => {
6715
6746
  const checkScreenSize = () => {
6716
6747
  const width = getWindowWidth();
6717
6748
  setIsMobile(width < MOBILE_WIDTH);
6718
6749
  setIsTablet(width < TABLET_WIDTH);
6750
+ setIsSmallMobile(width < SMALL_MOBILE_WIDTH);
6751
+ setIsExtraSmallMobile(width < EXTRA_SMALL_MOBILE_WIDTH);
6752
+ setIsUltraSmallMobile(width < ULTRA_SMALL_MOBILE_WIDTH);
6753
+ setIsTinyMobile(width < TINY_MOBILE_WIDTH);
6719
6754
  };
6720
6755
  checkScreenSize();
6721
6756
  window.addEventListener("resize", checkScreenSize);
@@ -6739,13 +6774,24 @@ var useMobile = () => {
6739
6774
  const getHeaderClasses = () => {
6740
6775
  return isMobile ? getMobileHeaderClasses() : getDesktopHeaderClasses();
6741
6776
  };
6777
+ const getVideoContainerClasses = () => {
6778
+ if (isTinyMobile) return "aspect-square";
6779
+ if (isExtraSmallMobile) return "aspect-[4/3]";
6780
+ if (isSmallMobile) return "aspect-[16/12]";
6781
+ return "aspect-video";
6782
+ };
6742
6783
  return {
6743
6784
  isMobile,
6744
6785
  isTablet,
6786
+ isSmallMobile,
6787
+ isExtraSmallMobile,
6788
+ isUltraSmallMobile,
6789
+ isTinyMobile,
6745
6790
  getFormContainerClasses,
6746
6791
  getHeaderClasses,
6747
6792
  getMobileHeaderClasses,
6748
6793
  getDesktopHeaderClasses,
6794
+ getVideoContainerClasses,
6749
6795
  getDeviceType
6750
6796
  };
6751
6797
  };
@@ -7708,8 +7754,9 @@ var ProgressBar2 = ({
7708
7754
  currentTime,
7709
7755
  duration,
7710
7756
  progressPercentage,
7711
- onSeek
7712
- }) => /* @__PURE__ */ jsx44("div", { className: "px-4 pb-2", children: /* @__PURE__ */ jsx44(
7757
+ onSeek,
7758
+ className = "px-4 pb-2"
7759
+ }) => /* @__PURE__ */ jsx44("div", { className, children: /* @__PURE__ */ jsx44(
7713
7760
  "input",
7714
7761
  {
7715
7762
  type: "range",
@@ -7728,18 +7775,20 @@ var VolumeControls = ({
7728
7775
  volume,
7729
7776
  isMuted,
7730
7777
  onVolumeChange,
7731
- onToggleMute
7778
+ onToggleMute,
7779
+ iconSize = 24,
7780
+ showSlider = true
7732
7781
  }) => /* @__PURE__ */ jsxs32("div", { className: "flex items-center gap-2", children: [
7733
7782
  /* @__PURE__ */ jsx44(
7734
7783
  IconButton_default,
7735
7784
  {
7736
- icon: isMuted ? /* @__PURE__ */ jsx44(SpeakerSlash, { size: 24 }) : /* @__PURE__ */ jsx44(SpeakerHigh2, { size: 24 }),
7785
+ icon: isMuted ? /* @__PURE__ */ jsx44(SpeakerSlash, { size: iconSize }) : /* @__PURE__ */ jsx44(SpeakerHigh2, { size: iconSize }),
7737
7786
  onClick: onToggleMute,
7738
7787
  "aria-label": isMuted ? "Unmute" : "Mute",
7739
7788
  className: "!bg-transparent !text-white hover:!bg-white/20"
7740
7789
  }
7741
7790
  ),
7742
- /* @__PURE__ */ jsx44(
7791
+ showSlider && /* @__PURE__ */ jsx44(
7743
7792
  "input",
7744
7793
  {
7745
7794
  type: "range",
@@ -7760,7 +7809,9 @@ var SpeedMenu = ({
7760
7809
  playbackRate,
7761
7810
  onToggleMenu,
7762
7811
  onSpeedChange,
7763
- isFullscreen
7812
+ isFullscreen,
7813
+ iconSize = 24,
7814
+ isTinyMobile = false
7764
7815
  }) => {
7765
7816
  const buttonRef = useRef9(null);
7766
7817
  const speedMenuContainerRef = useRef9(null);
@@ -7768,10 +7819,13 @@ var SpeedMenu = ({
7768
7819
  const getMenuPosition = () => {
7769
7820
  if (!buttonRef.current) return { top: 0, left: 0 };
7770
7821
  const rect = buttonRef.current.getBoundingClientRect();
7822
+ const menuHeight = isTinyMobile ? 150 : 180;
7823
+ const menuWidth = isTinyMobile ? 60 : 80;
7824
+ const padding = isTinyMobile ? 4 : 8;
7771
7825
  return {
7772
7826
  // Fixed coords are viewport-based — no scroll offsets.
7773
- top: Math.max(8, rect.top - 180),
7774
- left: Math.max(8, rect.right - 80)
7827
+ top: Math.max(padding, rect.top - menuHeight),
7828
+ left: Math.max(padding, rect.right - menuWidth)
7775
7829
  };
7776
7830
  };
7777
7831
  const position = getMenuPosition();
@@ -7824,7 +7878,7 @@ var SpeedMenu = ({
7824
7878
  IconButton_default,
7825
7879
  {
7826
7880
  ref: buttonRef,
7827
- icon: /* @__PURE__ */ jsx44(DotsThreeVertical2, { size: 24 }),
7881
+ icon: /* @__PURE__ */ jsx44(DotsThreeVertical2, { size: iconSize }),
7828
7882
  onClick: onToggleMenu,
7829
7883
  "aria-label": "Playback speed",
7830
7884
  "aria-haspopup": "menu",
@@ -7850,6 +7904,7 @@ var VideoPlayer = ({
7850
7904
  storageKey = "video-progress"
7851
7905
  }) => {
7852
7906
  const videoRef = useRef9(null);
7907
+ const { isUltraSmallMobile, isTinyMobile } = useMobile();
7853
7908
  const [isPlaying, setIsPlaying] = useState15(false);
7854
7909
  const [currentTime, setCurrentTime] = useState15(0);
7855
7910
  const [duration, setDuration] = useState15(0);
@@ -7952,6 +8007,12 @@ var VideoPlayer = ({
7952
8007
  video.removeEventListener("ended", onEnded);
7953
8008
  };
7954
8009
  }, []);
8010
+ useEffect15(() => {
8011
+ const video = videoRef.current;
8012
+ if (!video) return;
8013
+ video.setAttribute("playsinline", "");
8014
+ video.setAttribute("webkit-playsinline", "");
8015
+ }, []);
7955
8016
  useEffect15(() => {
7956
8017
  if (isPlaying) {
7957
8018
  showControlsWithTimer();
@@ -8158,6 +8219,31 @@ var VideoPlayer = ({
8158
8219
  };
8159
8220
  }, [isPlaying, clearControlsTimeout]);
8160
8221
  const progressPercentage = duration > 0 ? currentTime / duration * 100 : 0;
8222
+ const getIconSize2 = useCallback(() => {
8223
+ if (isTinyMobile) return 18;
8224
+ if (isUltraSmallMobile) return 20;
8225
+ return 24;
8226
+ }, [isTinyMobile, isUltraSmallMobile]);
8227
+ const getControlsPadding = useCallback(() => {
8228
+ if (isTinyMobile) return "px-2 pb-2 pt-1";
8229
+ if (isUltraSmallMobile) return "px-3 pb-3 pt-1";
8230
+ return "px-4 pb-4";
8231
+ }, [isTinyMobile, isUltraSmallMobile]);
8232
+ const getControlsGap = useCallback(() => {
8233
+ if (isTinyMobile) return "gap-1";
8234
+ if (isUltraSmallMobile) return "gap-2";
8235
+ return "gap-4";
8236
+ }, [isTinyMobile, isUltraSmallMobile]);
8237
+ const getProgressBarPadding = useCallback(() => {
8238
+ if (isTinyMobile) return "px-2 pb-1";
8239
+ if (isUltraSmallMobile) return "px-3 pb-1";
8240
+ return "px-4 pb-2";
8241
+ }, [isTinyMobile, isUltraSmallMobile]);
8242
+ const getCenterPlayButtonPosition = useCallback(() => {
8243
+ if (isTinyMobile) return "items-center justify-center -translate-y-12";
8244
+ if (isUltraSmallMobile) return "items-center justify-center -translate-y-8";
8245
+ return "items-center justify-center";
8246
+ }, [isTinyMobile, isUltraSmallMobile]);
8161
8247
  const getTopControlsOpacity = useCallback(() => {
8162
8248
  return showControls ? "opacity-100" : "opacity-0";
8163
8249
  }, [showControls]);
@@ -8265,8 +8351,9 @@ var VideoPlayer = ({
8265
8351
  ref: videoRef,
8266
8352
  src,
8267
8353
  poster,
8268
- className: "w-full h-full object-contain",
8354
+ className: "w-full h-full object-contain analytica-video",
8269
8355
  controlsList: "nodownload",
8356
+ playsInline: true,
8270
8357
  onTimeUpdate: handleTimeUpdate,
8271
8358
  onLoadedMetadata: handleLoadedMetadata,
8272
8359
  onClick: togglePlayPause,
@@ -8286,15 +8373,24 @@ var VideoPlayer = ({
8286
8373
  )
8287
8374
  }
8288
8375
  ),
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,
8376
+ !isPlaying && /* @__PURE__ */ jsx44(
8377
+ "div",
8291
8378
  {
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"
8379
+ className: cn(
8380
+ "absolute inset-0 flex bg-black/30 transition-opacity",
8381
+ getCenterPlayButtonPosition()
8382
+ ),
8383
+ children: /* @__PURE__ */ jsx44(
8384
+ IconButton_default,
8385
+ {
8386
+ icon: /* @__PURE__ */ jsx44(Play2, { size: 32, weight: "regular", className: "ml-1" }),
8387
+ onClick: togglePlayPause,
8388
+ "aria-label": "Play video",
8389
+ className: "!bg-transparent !text-white !w-auto !h-auto hover:!bg-transparent hover:!text-gray-200"
8390
+ }
8391
+ )
8296
8392
  }
8297
- ) }),
8393
+ ),
8298
8394
  /* @__PURE__ */ jsx44(
8299
8395
  "div",
8300
8396
  {
@@ -8327,58 +8423,72 @@ var VideoPlayer = ({
8327
8423
  currentTime,
8328
8424
  duration,
8329
8425
  progressPercentage,
8330
- onSeek: handleSeek
8426
+ onSeek: handleSeek,
8427
+ className: getProgressBarPadding()
8331
8428
  }
8332
8429
  ),
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
- }
8430
+ /* @__PURE__ */ jsxs32(
8431
+ "div",
8432
+ {
8433
+ className: cn(
8434
+ "flex items-center justify-between",
8435
+ getControlsPadding()
8364
8436
  ),
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
- ] })
8437
+ children: [
8438
+ /* @__PURE__ */ jsxs32("div", { className: cn("flex items-center", getControlsGap()), children: [
8439
+ /* @__PURE__ */ jsx44(
8440
+ IconButton_default,
8441
+ {
8442
+ icon: isPlaying ? /* @__PURE__ */ jsx44(Pause, { size: getIconSize2() }) : /* @__PURE__ */ jsx44(Play2, { size: getIconSize2() }),
8443
+ onClick: togglePlayPause,
8444
+ "aria-label": isPlaying ? "Pause" : "Play",
8445
+ className: "!bg-transparent !text-white hover:!bg-white/20"
8446
+ }
8447
+ ),
8448
+ /* @__PURE__ */ jsx44(
8449
+ VolumeControls,
8450
+ {
8451
+ volume,
8452
+ isMuted,
8453
+ onVolumeChange: handleVolumeChange,
8454
+ onToggleMute: toggleMute,
8455
+ iconSize: getIconSize2(),
8456
+ showSlider: !isUltraSmallMobile
8457
+ }
8458
+ ),
8459
+ subtitles && /* @__PURE__ */ jsx44(
8460
+ IconButton_default,
8461
+ {
8462
+ icon: /* @__PURE__ */ jsx44(ClosedCaptioning, { size: getIconSize2() }),
8463
+ onClick: toggleCaptions,
8464
+ "aria-label": showCaptions ? "Hide captions" : "Show captions",
8465
+ className: cn(
8466
+ "!bg-transparent hover:!bg-white/20",
8467
+ showCaptions ? "!text-primary-400" : "!text-white"
8468
+ )
8469
+ }
8470
+ ),
8471
+ /* @__PURE__ */ jsxs32(Text_default, { size: "sm", weight: "medium", color: "text-white", children: [
8472
+ formatTime(currentTime),
8473
+ " / ",
8474
+ formatTime(duration)
8475
+ ] })
8476
+ ] }),
8477
+ /* @__PURE__ */ jsx44("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ jsx44(
8478
+ SpeedMenu,
8479
+ {
8480
+ showSpeedMenu,
8481
+ playbackRate,
8482
+ onToggleMenu: toggleSpeedMenu,
8483
+ onSpeedChange: handleSpeedChange,
8484
+ iconSize: getIconSize2(),
8485
+ isTinyMobile,
8486
+ isFullscreen
8487
+ }
8488
+ ) })
8489
+ ]
8490
+ }
8491
+ )
8382
8492
  ]
8383
8493
  }
8384
8494
  )