analytica-frontend-lib 1.1.57 → 1.1.58

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
@@ -4325,7 +4325,8 @@ import {
4325
4325
  forwardRef as forwardRef12,
4326
4326
  Fragment as Fragment4,
4327
4327
  useState as useState10,
4328
- useRef as useRef7
4328
+ useRef as useRef7,
4329
+ useEffect as useEffect9
4329
4330
  } from "react";
4330
4331
  import {
4331
4332
  CaretRight as CaretRight2,
@@ -5173,6 +5174,8 @@ var CardAudio = forwardRef12(
5173
5174
  const [showSpeedMenu, setShowSpeedMenu] = useState10(false);
5174
5175
  const [playbackRate, setPlaybackRate] = useState10(1);
5175
5176
  const audioRef = useRef7(null);
5177
+ const volumeControlRef = useRef7(null);
5178
+ const speedMenuRef = useRef7(null);
5176
5179
  const formatTime2 = (time) => {
5177
5180
  const minutes = Math.floor(time / 60);
5178
5181
  const seconds = Math.floor(time % 60);
@@ -5224,9 +5227,11 @@ var CardAudio = forwardRef12(
5224
5227
  };
5225
5228
  const toggleVolumeControl = () => {
5226
5229
  setShowVolumeControl(!showVolumeControl);
5230
+ setShowSpeedMenu(false);
5227
5231
  };
5228
5232
  const toggleSpeedMenu = () => {
5229
5233
  setShowSpeedMenu(!showSpeedMenu);
5234
+ setShowVolumeControl(false);
5230
5235
  };
5231
5236
  const handleSpeedChange = (speed) => {
5232
5237
  setPlaybackRate(speed);
@@ -5244,6 +5249,20 @@ var CardAudio = forwardRef12(
5244
5249
  }
5245
5250
  return /* @__PURE__ */ jsx28(SpeakerHigh, { size: 24 });
5246
5251
  };
5252
+ useEffect9(() => {
5253
+ const handleClickOutside = (event) => {
5254
+ if (volumeControlRef.current && !volumeControlRef.current.contains(event.target)) {
5255
+ setShowVolumeControl(false);
5256
+ }
5257
+ if (speedMenuRef.current && !speedMenuRef.current.contains(event.target)) {
5258
+ setShowSpeedMenu(false);
5259
+ }
5260
+ };
5261
+ document.addEventListener("mousedown", handleClickOutside);
5262
+ return () => {
5263
+ document.removeEventListener("mousedown", handleClickOutside);
5264
+ };
5265
+ }, []);
5247
5266
  return /* @__PURE__ */ jsxs21(
5248
5267
  CardBase,
5249
5268
  {
@@ -5332,7 +5351,7 @@ var CardAudio = forwardRef12(
5332
5351
  }
5333
5352
  ) }),
5334
5353
  /* @__PURE__ */ jsx28("p", { className: "text-text-800 text-md font-medium min-w-[2.5rem]", children: formatTime2(duration) }),
5335
- /* @__PURE__ */ jsxs21("div", { className: "relative h-6", children: [
5354
+ /* @__PURE__ */ jsxs21("div", { className: "relative h-6", ref: volumeControlRef, children: [
5336
5355
  /* @__PURE__ */ jsx28(
5337
5356
  "button",
5338
5357
  {
@@ -5394,7 +5413,7 @@ var CardAudio = forwardRef12(
5394
5413
  }
5395
5414
  )
5396
5415
  ] }),
5397
- /* @__PURE__ */ jsxs21("div", { className: "relative h-6", children: [
5416
+ /* @__PURE__ */ jsxs21("div", { className: "relative h-6", ref: speedMenuRef, children: [
5398
5417
  /* @__PURE__ */ jsx28(
5399
5418
  "button",
5400
5419
  {
@@ -6042,7 +6061,7 @@ var HeaderAlternative = forwardRef14(
6042
6061
  // src/components/AlertDialog/AlertDialog.tsx
6043
6062
  import {
6044
6063
  forwardRef as forwardRef15,
6045
- useEffect as useEffect9
6064
+ useEffect as useEffect10
6046
6065
  } from "react";
6047
6066
  import { Fragment as Fragment6, jsx as jsx31, jsxs as jsxs24 } from "react/jsx-runtime";
6048
6067
  var SIZE_CLASSES11 = {
@@ -6070,7 +6089,7 @@ var AlertDialog = forwardRef15(
6070
6089
  size = "medium",
6071
6090
  ...props
6072
6091
  }, ref) => {
6073
- useEffect9(() => {
6092
+ useEffect10(() => {
6074
6093
  if (!isOpen || !closeOnEscape) return;
6075
6094
  const handleEscape = (event) => {
6076
6095
  if (event.key === "Escape") {
@@ -6080,7 +6099,7 @@ var AlertDialog = forwardRef15(
6080
6099
  document.addEventListener("keydown", handleEscape);
6081
6100
  return () => document.removeEventListener("keydown", handleEscape);
6082
6101
  }, [isOpen, closeOnEscape]);
6083
- useEffect9(() => {
6102
+ useEffect10(() => {
6084
6103
  if (isOpen) {
6085
6104
  document.body.style.overflow = "hidden";
6086
6105
  } else {
@@ -6166,7 +6185,7 @@ var AlertDialog = forwardRef15(
6166
6185
  AlertDialog.displayName = "AlertDialog";
6167
6186
 
6168
6187
  // src/components/MultipleChoice/MultipleChoice.tsx
6169
- import { useEffect as useEffect10, useState as useState13 } from "react";
6188
+ import { useEffect as useEffect11, useState as useState13 } from "react";
6170
6189
  import { CheckCircle as CheckCircle5, XCircle as XCircle4, Check as Check4 } from "phosphor-react";
6171
6190
  import { jsx as jsx32, jsxs as jsxs25 } from "react/jsx-runtime";
6172
6191
  var MultipleChoiceList = ({
@@ -6179,7 +6198,7 @@ var MultipleChoiceList = ({
6179
6198
  mode = "interactive"
6180
6199
  }) => {
6181
6200
  const [actualValue, setActualValue] = useState13(selectedValues);
6182
- useEffect10(() => {
6201
+ useEffect11(() => {
6183
6202
  setActualValue(selectedValues);
6184
6203
  }, [selectedValues]);
6185
6204
  const getStatusBadge2 = (status) => {
@@ -6299,7 +6318,7 @@ var MultipleChoiceList = ({
6299
6318
  };
6300
6319
 
6301
6320
  // src/hooks/useMobile.ts
6302
- import { useState as useState14, useEffect as useEffect11 } from "react";
6321
+ import { useState as useState14, useEffect as useEffect12 } from "react";
6303
6322
  var MOBILE_WIDTH = 500;
6304
6323
  var TABLET_WIDTH = 931;
6305
6324
  var DEFAULT_WIDTH = 1200;
@@ -6316,7 +6335,7 @@ var getDeviceType = () => {
6316
6335
  var useMobile = () => {
6317
6336
  const [isMobile, setIsMobile] = useState14(false);
6318
6337
  const [isTablet, setIsTablet] = useState14(false);
6319
- useEffect11(() => {
6338
+ useEffect12(() => {
6320
6339
  const checkScreenSize = () => {
6321
6340
  const width = getWindowWidth();
6322
6341
  setIsMobile(width < MOBILE_WIDTH);
@@ -6358,7 +6377,7 @@ var useMobile = () => {
6358
6377
  // src/components/Select/Select.tsx
6359
6378
  import { create as create5, useStore as useStore4 } from "zustand";
6360
6379
  import {
6361
- useEffect as useEffect12,
6380
+ useEffect as useEffect13,
6362
6381
  useRef as useRef8,
6363
6382
  forwardRef as forwardRef16,
6364
6383
  isValidElement as isValidElement4,
@@ -6489,13 +6508,13 @@ var Select = ({
6489
6508
  search(children2);
6490
6509
  return found;
6491
6510
  };
6492
- useEffect12(() => {
6511
+ useEffect13(() => {
6493
6512
  if (!selectedLabel && defaultValue) {
6494
6513
  const label2 = findLabelForValue(children, defaultValue);
6495
6514
  if (label2) store.setState({ selectedLabel: label2 });
6496
6515
  }
6497
6516
  }, [children, defaultValue, selectedLabel]);
6498
- useEffect12(() => {
6517
+ useEffect13(() => {
6499
6518
  const handleClickOutside = (event) => {
6500
6519
  if (selectRef.current && !selectRef.current.contains(event.target)) {
6501
6520
  setOpen(false);
@@ -6530,7 +6549,7 @@ var Select = ({
6530
6549
  document.removeEventListener("keydown", handleArrowKeys);
6531
6550
  };
6532
6551
  }, [open]);
6533
- useEffect12(() => {
6552
+ useEffect13(() => {
6534
6553
  if (propValue) {
6535
6554
  setValue(propValue);
6536
6555
  const label2 = findLabelForValue(children, propValue);
@@ -6711,7 +6730,7 @@ var Select_default = Select;
6711
6730
  // src/components/Menu/Menu.tsx
6712
6731
  import { create as create6, useStore as useStore5 } from "zustand";
6713
6732
  import {
6714
- useEffect as useEffect13,
6733
+ useEffect as useEffect14,
6715
6734
  useRef as useRef9,
6716
6735
  forwardRef as forwardRef17,
6717
6736
  isValidElement as isValidElement5,
@@ -6753,7 +6772,7 @@ var Menu = forwardRef17(
6753
6772
  storeRef.current ??= createMenuStore(onValueChange);
6754
6773
  const store = storeRef.current;
6755
6774
  const { setValue } = useStore5(store, (s) => s);
6756
- useEffect13(() => {
6775
+ useEffect14(() => {
6757
6776
  setValue(propValue ?? defaultValue);
6758
6777
  }, [defaultValue, propValue, setValue]);
6759
6778
  const baseClasses = variant === "menu-overflow" ? "w-fit py-2 flex flex-row items-center justify-center" : "w-full py-2 flex flex-row items-center justify-center";
@@ -6957,7 +6976,7 @@ var MenuOverflow = ({
6957
6976
  const containerRef = useRef9(null);
6958
6977
  const [showLeftArrow, setShowLeftArrow] = useState15(false);
6959
6978
  const [showRightArrow, setShowRightArrow] = useState15(false);
6960
- useEffect13(() => {
6979
+ useEffect14(() => {
6961
6980
  const checkScroll = () => internalCheckScroll(
6962
6981
  containerRef.current,
6963
6982
  setShowLeftArrow,
@@ -7285,7 +7304,7 @@ var NotFound_default = NotFound;
7285
7304
  import {
7286
7305
  useRef as useRef10,
7287
7306
  useState as useState16,
7288
- useEffect as useEffect14,
7307
+ useEffect as useEffect15,
7289
7308
  useCallback as useCallback2
7290
7309
  } from "react";
7291
7310
  import { createPortal } from "react-dom";
@@ -7368,6 +7387,8 @@ var SpeedMenu = ({
7368
7387
  isFullscreen
7369
7388
  }) => {
7370
7389
  const buttonRef = useRef10(null);
7390
+ const speedMenuContainerRef = useRef10(null);
7391
+ const speedMenuRef = useRef10(null);
7371
7392
  const getMenuPosition = () => {
7372
7393
  if (!buttonRef.current) return { top: 0, left: 0 };
7373
7394
  const rect = buttonRef.current.getBoundingClientRect();
@@ -7378,9 +7399,26 @@ var SpeedMenu = ({
7378
7399
  };
7379
7400
  };
7380
7401
  const position = getMenuPosition();
7402
+ useEffect15(() => {
7403
+ const handleClickOutside = (event) => {
7404
+ const target = event.target;
7405
+ const isOutsideContainer = speedMenuContainerRef.current && !speedMenuContainerRef.current.contains(target);
7406
+ const isOutsideMenu = speedMenuRef.current && !speedMenuRef.current.contains(target);
7407
+ if (isOutsideContainer && isOutsideMenu) {
7408
+ onToggleMenu();
7409
+ }
7410
+ };
7411
+ if (showSpeedMenu) {
7412
+ document.addEventListener("mousedown", handleClickOutside);
7413
+ }
7414
+ return () => {
7415
+ document.removeEventListener("mousedown", handleClickOutside);
7416
+ };
7417
+ }, [showSpeedMenu, onToggleMenu]);
7381
7418
  const menuContent = /* @__PURE__ */ jsx37(
7382
7419
  "div",
7383
7420
  {
7421
+ ref: speedMenuRef,
7384
7422
  role: "menu",
7385
7423
  "aria-label": "Playback speed",
7386
7424
  className: isFullscreen ? "absolute bottom-12 right-0 bg-black/90 rounded-lg p-2 min-w-20 z-[9999]" : "fixed bg-black/90 rounded-lg p-2 min-w-20 z-[9999]",
@@ -7405,7 +7443,7 @@ var SpeedMenu = ({
7405
7443
  }
7406
7444
  );
7407
7445
  const portalContent = typeof window !== "undefined" && typeof document !== "undefined" ? createPortal(menuContent, document.body) : null;
7408
- return /* @__PURE__ */ jsxs30("div", { className: "relative", children: [
7446
+ return /* @__PURE__ */ jsxs30("div", { className: "relative", ref: speedMenuContainerRef, children: [
7409
7447
  /* @__PURE__ */ jsx37(
7410
7448
  IconButton_default,
7411
7449
  {
@@ -7445,7 +7483,7 @@ var VideoPlayer = ({
7445
7483
  const [showControls, setShowControls] = useState16(true);
7446
7484
  const [hasCompleted, setHasCompleted] = useState16(false);
7447
7485
  const [showCaptions, setShowCaptions] = useState16(false);
7448
- useEffect14(() => {
7486
+ useEffect15(() => {
7449
7487
  setHasCompleted(false);
7450
7488
  }, [src]);
7451
7489
  const [playbackRate, setPlaybackRate] = useState16(1);
@@ -7517,13 +7555,13 @@ var VideoPlayer = ({
7517
7555
  }, LEAVE_HIDE_TIMEOUT);
7518
7556
  }
7519
7557
  }, [isFullscreen, clearControlsTimeout, isUserInteracting]);
7520
- useEffect14(() => {
7558
+ useEffect15(() => {
7521
7559
  if (videoRef.current) {
7522
7560
  videoRef.current.volume = volume;
7523
7561
  videoRef.current.muted = isMuted;
7524
7562
  }
7525
7563
  }, [volume, isMuted]);
7526
- useEffect14(() => {
7564
+ useEffect15(() => {
7527
7565
  const video = videoRef.current;
7528
7566
  if (!video) return;
7529
7567
  const onPlay = () => setIsPlaying(true);
@@ -7538,7 +7576,7 @@ var VideoPlayer = ({
7538
7576
  video.removeEventListener("ended", onEnded);
7539
7577
  };
7540
7578
  }, []);
7541
- useEffect14(() => {
7579
+ useEffect15(() => {
7542
7580
  if (isPlaying) {
7543
7581
  showControlsWithTimer();
7544
7582
  } else {
@@ -7550,7 +7588,7 @@ var VideoPlayer = ({
7550
7588
  }
7551
7589
  }
7552
7590
  }, [isPlaying, isFullscreen, showControlsWithTimer, clearControlsTimeout]);
7553
- useEffect14(() => {
7591
+ useEffect15(() => {
7554
7592
  const handleFullscreenChange = () => {
7555
7593
  const isCurrentlyFullscreen = !!document.fullscreenElement;
7556
7594
  setIsFullscreen(isCurrentlyFullscreen);
@@ -7563,7 +7601,7 @@ var VideoPlayer = ({
7563
7601
  document.removeEventListener("fullscreenchange", handleFullscreenChange);
7564
7602
  };
7565
7603
  }, [showControlsWithTimer]);
7566
- useEffect14(() => {
7604
+ useEffect15(() => {
7567
7605
  const init = () => {
7568
7606
  if (!isFullscreen) {
7569
7607
  showControlsWithTimer();
@@ -7596,7 +7634,7 @@ var VideoPlayer = ({
7596
7634
  if (hasValidSaved) return saved;
7597
7635
  return void 0;
7598
7636
  }, [autoSave, storageKey, src, initialTime]);
7599
- useEffect14(() => {
7637
+ useEffect15(() => {
7600
7638
  const start = getInitialTime();
7601
7639
  if (start !== void 0 && videoRef.current) {
7602
7640
  videoRef.current.currentTime = start;
@@ -7717,12 +7755,12 @@ var VideoPlayer = ({
7717
7755
  setDuration(videoRef.current.duration);
7718
7756
  }
7719
7757
  }, []);
7720
- useEffect14(() => {
7758
+ useEffect15(() => {
7721
7759
  if (trackRef.current?.track) {
7722
7760
  trackRef.current.track.mode = showCaptions && subtitles ? "showing" : "hidden";
7723
7761
  }
7724
7762
  }, [subtitles, showCaptions]);
7725
- useEffect14(() => {
7763
+ useEffect15(() => {
7726
7764
  const handleVisibilityChange = () => {
7727
7765
  if (document.hidden && isPlaying && videoRef.current) {
7728
7766
  videoRef.current.pause();
@@ -8097,7 +8135,7 @@ var Whiteboard_default = Whiteboard;
8097
8135
  import {
8098
8136
  createContext,
8099
8137
  useContext,
8100
- useEffect as useEffect15,
8138
+ useEffect as useEffect16,
8101
8139
  useState as useState18,
8102
8140
  useCallback as useCallback4,
8103
8141
  useMemo as useMemo4
@@ -8162,7 +8200,7 @@ var AuthProvider = ({
8162
8200
  tokens: void 0
8163
8201
  }));
8164
8202
  }, [signOutFn]);
8165
- useEffect15(() => {
8203
+ useEffect16(() => {
8166
8204
  checkAuth();
8167
8205
  }, [checkAuth]);
8168
8206
  const contextValue = useMemo4(
@@ -8316,7 +8354,7 @@ function createZustandAuthAdapter(useAuthStore) {
8316
8354
  }
8317
8355
 
8318
8356
  // src/components/Auth/useUrlAuthentication.ts
8319
- import { useEffect as useEffect16, useRef as useRef11 } from "react";
8357
+ import { useEffect as useEffect17, useRef as useRef11 } from "react";
8320
8358
  import { useLocation as useLocation2 } from "react-router-dom";
8321
8359
  var getAuthParams = (location, extractParams) => {
8322
8360
  const searchParams = new URLSearchParams(location.search);
@@ -8365,7 +8403,7 @@ var handleUserData = (responseData, setUser) => {
8365
8403
  function useUrlAuthentication(options) {
8366
8404
  const location = useLocation2();
8367
8405
  const processedRef = useRef11(false);
8368
- useEffect16(() => {
8406
+ useEffect17(() => {
8369
8407
  const handleAuthentication = async () => {
8370
8408
  if (processedRef.current) {
8371
8409
  return;
@@ -8458,7 +8496,7 @@ import {
8458
8496
  } from "phosphor-react";
8459
8497
  import {
8460
8498
  forwardRef as forwardRef19,
8461
- useEffect as useEffect17,
8499
+ useEffect as useEffect18,
8462
8500
  useMemo as useMemo6,
8463
8501
  useId as useId11,
8464
8502
  useState as useState19,
@@ -9121,7 +9159,7 @@ var getStatusStyles = (variantCorrect) => {
9121
9159
  };
9122
9160
  var Quiz = forwardRef19(({ children, className, variant = "default", ...props }, ref) => {
9123
9161
  const { setVariant } = useQuizStore();
9124
- useEffect17(() => {
9162
+ useEffect18(() => {
9125
9163
  setVariant(variant);
9126
9164
  }, [variant, setVariant]);
9127
9165
  return /* @__PURE__ */ jsx40("div", { ref, className: cn("flex flex-col", className), ...props, children });
@@ -9130,7 +9168,7 @@ var QuizHeaderResult = forwardRef19(
9130
9168
  ({ className, ...props }, ref) => {
9131
9169
  const { getQuestionResultByQuestionId, getCurrentQuestion } = useQuizStore();
9132
9170
  const [status, setStatus] = useState19(void 0);
9133
- useEffect17(() => {
9171
+ useEffect18(() => {
9134
9172
  const cq = getCurrentQuestion();
9135
9173
  if (!cq) {
9136
9174
  setStatus(void 0);
@@ -9481,7 +9519,7 @@ var QuizDissertative = ({ paddingBottom }) => {
9481
9519
  textareaRef.current.style.height = `${newHeight}px`;
9482
9520
  }
9483
9521
  }, []);
9484
- useEffect17(() => {
9522
+ useEffect18(() => {
9485
9523
  adjustTextareaHeight();
9486
9524
  }, [currentAnswer, adjustTextareaHeight]);
9487
9525
  if (!currentQuestion) {
@@ -10646,7 +10684,7 @@ var loadingModal_default = LoadingModal;
10646
10684
 
10647
10685
  // src/components/NotificationCard/NotificationCard.tsx
10648
10686
  import { DotsThreeVertical as DotsThreeVertical3, Bell as Bell2 } from "phosphor-react";
10649
- import { useState as useState20, useEffect as useEffect18 } from "react";
10687
+ import { useState as useState20, useEffect as useEffect19 } from "react";
10650
10688
 
10651
10689
  // src/store/notificationStore.ts
10652
10690
  import { create as create8 } from "zustand";
@@ -11149,7 +11187,7 @@ var NotificationCenter = ({
11149
11187
  const handleDesktopClick = () => {
11150
11188
  onToggleActive?.();
11151
11189
  };
11152
- useEffect18(() => {
11190
+ useEffect19(() => {
11153
11191
  if (isActive) {
11154
11192
  onFetchNotifications?.();
11155
11193
  }