analytica-frontend-lib 1.2.0 → 1.2.2

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.js CHANGED
@@ -8237,7 +8237,7 @@ var StatCard = ({ item, showPlaceholder = false }) => {
8237
8237
  {
8238
8238
  size: "xs",
8239
8239
  weight: "bold",
8240
- className: "uppercase text-[8px] leading-[9px] text-text-800 self-stretch",
8240
+ className: "uppercase text-[8px] leading-[9px] text-text-800 whitespace-nowrap",
8241
8241
  children: item.label
8242
8242
  }
8243
8243
  )
@@ -8273,8 +8273,18 @@ var StatisticsCard = ({
8273
8273
  className: `bg-background rounded-xl p-4 h-auto lg:h-[185px] flex flex-col gap-2 ${className}`,
8274
8274
  children: [
8275
8275
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex flex-row justify-between items-center gap-4", children: [
8276
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Text_default, { as: "h3", size: "sm", weight: "medium", color: "text-text-600", children: title }),
8277
- dropdownOptions && dropdownOptions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "w-[99px]", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
8276
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8277
+ Text_default,
8278
+ {
8279
+ as: "h3",
8280
+ size: "sm",
8281
+ weight: "medium",
8282
+ color: "text-text-600",
8283
+ className: "flex-1 min-w-0",
8284
+ children: title
8285
+ }
8286
+ ),
8287
+ dropdownOptions && dropdownOptions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "w-[120px] min-w-[90px] sm:shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
8278
8288
  Select_default,
8279
8289
  {
8280
8290
  value: selectedDropdownValue,
@@ -8284,12 +8294,20 @@ var StatisticsCard = ({
8284
8294
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8285
8295
  SelectTrigger,
8286
8296
  {
8287
- className: "border border-border-300 rounded whitespace-nowrap",
8297
+ className: "border border-border-300 rounded [&>span]:whitespace-nowrap [&>span]:overflow-hidden [&>span]:text-ellipsis",
8288
8298
  "aria-label": dropdownAriaLabel,
8289
8299
  children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SelectValue, { placeholder: selectPlaceholder })
8290
8300
  }
8291
8301
  ),
8292
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SelectContent, { children: dropdownOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SelectItem, { value: option.value, children: option.label }, option.value)) })
8302
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SelectContent, { className: "min-w-[120px]", children: dropdownOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8303
+ SelectItem,
8304
+ {
8305
+ value: option.value,
8306
+ className: "whitespace-nowrap",
8307
+ children: option.label
8308
+ },
8309
+ option.value
8310
+ )) })
8293
8311
  ]
8294
8312
  }
8295
8313
  ) })
@@ -11268,10 +11286,15 @@ var QuizAlternative = ({ paddingBottom }) => {
11268
11286
  const isSelected = currentQuestionResult?.selectedOptions.some(
11269
11287
  (selectedOption) => selectedOption.optionId === option.id
11270
11288
  );
11271
- if (isCorrectOption) {
11272
- status = "correct" /* CORRECT */;
11273
- } else if (isSelected && !isCorrectOption) {
11274
- status = "incorrect" /* INCORRECT */;
11289
+ const shouldShowCorrectAnswers = currentQuestionResult?.answerStatus !== "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */ && currentQuestionResult?.answerStatus !== "NAO_RESPONDIDO" /* NAO_RESPONDIDO */;
11290
+ if (shouldShowCorrectAnswers) {
11291
+ if (isCorrectOption) {
11292
+ status = "correct" /* CORRECT */;
11293
+ } else if (isSelected && !isCorrectOption) {
11294
+ status = "incorrect" /* INCORRECT */;
11295
+ } else {
11296
+ status = "neutral" /* NEUTRAL */;
11297
+ }
11275
11298
  } else {
11276
11299
  status = "neutral" /* NEUTRAL */;
11277
11300
  }
@@ -11369,10 +11392,15 @@ var QuizMultipleChoice = ({ paddingBottom }) => {
11369
11392
  const isSelected = currentQuestionResult?.selectedOptions?.some(
11370
11393
  (op) => op.optionId === option.id
11371
11394
  );
11372
- if (isCorrectOption) {
11373
- status = "correct" /* CORRECT */;
11374
- } else if (isSelected && !isCorrectOption) {
11375
- status = "incorrect" /* INCORRECT */;
11395
+ const shouldShowCorrectAnswers = currentQuestionResult?.answerStatus !== "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */ && currentQuestionResult?.answerStatus !== "NAO_RESPONDIDO" /* NAO_RESPONDIDO */;
11396
+ if (shouldShowCorrectAnswers) {
11397
+ if (isCorrectOption) {
11398
+ status = "correct" /* CORRECT */;
11399
+ } else if (isSelected && !isCorrectOption) {
11400
+ status = "incorrect" /* INCORRECT */;
11401
+ } else {
11402
+ status = "neutral" /* NEUTRAL */;
11403
+ }
11376
11404
  } else {
11377
11405
  status = "neutral" /* NEUTRAL */;
11378
11406
  }
@@ -11475,8 +11503,8 @@ var QuizTrueOrFalse = ({ paddingBottom }) => {
11475
11503
  isCorrect: false
11476
11504
  }
11477
11505
  ];
11478
- const getLetterByIndex = (index) => String.fromCharCode(97 + index);
11479
- const isDefaultVariant = variant == "default";
11506
+ const getLetterByIndex = (index) => String.fromCodePoint(97 + index);
11507
+ const isDefaultVariant = variant === "default";
11480
11508
  return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
11481
11509
  /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(QuizSubTitle, { subTitle: "Alternativas" }),
11482
11510
  /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(QuizContainer, { className: cn("", paddingBottom), children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "flex flex-col gap-3.5", children: options.map((option, index) => {
@@ -11491,7 +11519,7 @@ var QuizTrueOrFalse = ({ paddingBottom }) => {
11491
11519
  {
11492
11520
  className: cn(
11493
11521
  "flex flex-row justify-between items-center gap-2 p-2 rounded-md",
11494
- !isDefaultVariant ? getStatusStyles(variantCorrect) : ""
11522
+ isDefaultVariant ? "" : getStatusStyles(variantCorrect)
11495
11523
  ),
11496
11524
  children: [
11497
11525
  /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "text-text-900 text-sm", children: getLetterByIndex(index).concat(") ").concat(option.label) }),
@@ -11592,7 +11620,7 @@ var QuizConnectDots = ({ paddingBottom }) => {
11592
11620
  return next;
11593
11621
  });
11594
11622
  };
11595
- const getLetterByIndex = (index) => String.fromCharCode(97 + index);
11623
+ const getLetterByIndex = (index) => String.fromCodePoint(97 + index);
11596
11624
  const isDefaultVariant = variant === "default";
11597
11625
  const assignedDots = new Set(
11598
11626
  userAnswers.map((a) => a.dotOption).filter(Boolean)
@@ -11608,7 +11636,7 @@ var QuizConnectDots = ({ paddingBottom }) => {
11608
11636
  {
11609
11637
  className: cn(
11610
11638
  "flex flex-row justify-between items-center gap-2 p-2 rounded-md",
11611
- !isDefaultVariant ? getStatusStyles(variantCorrect) : ""
11639
+ isDefaultVariant ? "" : getStatusStyles(variantCorrect)
11612
11640
  ),
11613
11641
  children: [
11614
11642
  /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "text-text-900 text-sm", children: getLetterByIndex(index) + ") " + option.label }),
@@ -11690,8 +11718,10 @@ var QuizFill = ({ paddingBottom }) => {
11690
11718
  const [answers, setAnswers] = (0, import_react36.useState)({});
11691
11719
  const baseId = (0, import_react36.useId)();
11692
11720
  const getAvailableOptionsForSelect = (selectId) => {
11693
- const usedOptions = Object.entries(answers).filter(([key]) => key !== selectId).map(([, value]) => value);
11694
- return options.filter((option) => !usedOptions.includes(option));
11721
+ const usedOptions = new Set(
11722
+ Object.entries(answers).filter(([key]) => key !== selectId).map(([, value]) => value)
11723
+ );
11724
+ return options.filter((option) => !usedOptions.has(option));
11695
11725
  };
11696
11726
  const handleSelectChange = (selectId, value) => {
11697
11727
  const newAnswers = { ...answers, [selectId]: value };
@@ -12576,7 +12606,11 @@ var QuizBadge = ({
12576
12606
  };
12577
12607
  var QuizHeaderResult = (0, import_react38.forwardRef)(
12578
12608
  ({ className, ...props }, ref) => {
12579
- const { getQuestionResultByQuestionId, getCurrentQuestion } = useQuizStore();
12609
+ const {
12610
+ getQuestionResultByQuestionId,
12611
+ getCurrentQuestion,
12612
+ questionsResult
12613
+ } = useQuizStore();
12580
12614
  const [status, setStatus] = (0, import_react38.useState)(void 0);
12581
12615
  (0, import_react38.useEffect)(() => {
12582
12616
  const cq = getCurrentQuestion();
@@ -12589,9 +12623,13 @@ var QuizHeaderResult = (0, import_react38.forwardRef)(
12589
12623
  }, [
12590
12624
  getCurrentQuestion,
12591
12625
  getQuestionResultByQuestionId,
12592
- getCurrentQuestion()?.id
12626
+ getCurrentQuestion()?.id,
12627
+ questionsResult
12593
12628
  ]);
12594
12629
  const getClassesByAnswersStatus = () => {
12630
+ if (status === void 0) {
12631
+ return "bg-gray-100";
12632
+ }
12595
12633
  switch (status) {
12596
12634
  case "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */:
12597
12635
  return "bg-success-background";
@@ -12604,6 +12642,9 @@ var QuizHeaderResult = (0, import_react38.forwardRef)(
12604
12642
  }
12605
12643
  };
12606
12644
  const getLabelByAnswersStatus = () => {
12645
+ if (status === void 0) {
12646
+ return "Carregando...";
12647
+ }
12607
12648
  switch (status) {
12608
12649
  case "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */:
12609
12650
  return "\u{1F389} Parab\xE9ns!!";
@@ -12612,6 +12653,7 @@ var QuizHeaderResult = (0, import_react38.forwardRef)(
12612
12653
  case "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */:
12613
12654
  return "Avalia\xE7\xE3o pendente";
12614
12655
  case "NAO_RESPONDIDO" /* NAO_RESPONDIDO */:
12656
+ return "N\xE3o foi dessa vez...voc\xEA deixou a resposta em branco";
12615
12657
  default:
12616
12658
  return "N\xE3o foi dessa vez...voc\xEA deixou a resposta em branco";
12617
12659
  }
@@ -12677,6 +12719,37 @@ var QuizResultTitle = (0, import_react38.forwardRef)(({ className, ...props }, r
12677
12719
  }
12678
12720
  );
12679
12721
  });
12722
+ var updateDifficultyStats = (stats, difficulty, isCorrect) => {
12723
+ if (difficulty === "FACIL" /* FACIL */) {
12724
+ stats.totalEasyQuestions++;
12725
+ if (isCorrect) stats.correctEasyAnswers++;
12726
+ } else if (difficulty === "MEDIO" /* MEDIO */) {
12727
+ stats.totalMediumQuestions++;
12728
+ if (isCorrect) stats.correctMediumAnswers++;
12729
+ } else if (difficulty === "DIFICIL" /* DIFICIL */) {
12730
+ stats.totalDifficultQuestions++;
12731
+ if (isCorrect) stats.correctDifficultAnswers++;
12732
+ }
12733
+ };
12734
+ var calculateAnswerStatistics = (answers) => {
12735
+ const stats = {
12736
+ correctAnswers: 0,
12737
+ correctEasyAnswers: 0,
12738
+ correctMediumAnswers: 0,
12739
+ correctDifficultAnswers: 0,
12740
+ totalEasyQuestions: 0,
12741
+ totalMediumQuestions: 0,
12742
+ totalDifficultQuestions: 0
12743
+ };
12744
+ for (const answer of answers) {
12745
+ const isCorrect = answer.answerStatus === "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */;
12746
+ if (isCorrect) {
12747
+ stats.correctAnswers++;
12748
+ }
12749
+ updateDifficultyStats(stats, answer.difficultyLevel, isCorrect);
12750
+ }
12751
+ return stats;
12752
+ };
12680
12753
  var QuizResultPerformance = (0, import_react38.forwardRef)(({ showDetails = true, ...props }, ref) => {
12681
12754
  const {
12682
12755
  getTotalQuestions,
@@ -12686,38 +12759,16 @@ var QuizResultPerformance = (0, import_react38.forwardRef)(({ showDetails = true
12686
12759
  } = useQuizStore();
12687
12760
  const totalQuestions = getTotalQuestions();
12688
12761
  const questionResult = getQuestionResult();
12689
- let correctAnswers = 0;
12690
- let correctEasyAnswers = 0;
12691
- let correctMediumAnswers = 0;
12692
- let correctDifficultAnswers = 0;
12693
- let totalEasyQuestions = 0;
12694
- let totalMediumQuestions = 0;
12695
- let totalDifficultQuestions = 0;
12696
- if (questionResult) {
12697
- questionResult.answers.forEach((answer) => {
12698
- const isCorrect = answer.answerStatus == "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */;
12699
- if (isCorrect) {
12700
- correctAnswers++;
12701
- }
12702
- if (answer.difficultyLevel === "FACIL" /* FACIL */) {
12703
- totalEasyQuestions++;
12704
- if (isCorrect) {
12705
- correctEasyAnswers++;
12706
- }
12707
- } else if (answer.difficultyLevel === "MEDIO" /* MEDIO */) {
12708
- totalMediumQuestions++;
12709
- if (isCorrect) {
12710
- correctMediumAnswers++;
12711
- }
12712
- } else if (answer.difficultyLevel === "DIFICIL" /* DIFICIL */) {
12713
- totalDifficultQuestions++;
12714
- if (isCorrect) {
12715
- correctDifficultAnswers++;
12716
- }
12717
- }
12718
- });
12719
- }
12720
- const percentage = totalQuestions > 0 ? Math.round(correctAnswers / totalQuestions * 100) : 0;
12762
+ const stats = questionResult ? calculateAnswerStatistics(questionResult.answers) : {
12763
+ correctAnswers: 0,
12764
+ correctEasyAnswers: 0,
12765
+ correctMediumAnswers: 0,
12766
+ correctDifficultAnswers: 0,
12767
+ totalEasyQuestions: 0,
12768
+ totalMediumQuestions: 0,
12769
+ totalDifficultQuestions: 0
12770
+ };
12771
+ const percentage = totalQuestions > 0 ? Math.round(stats.correctAnswers / totalQuestions * 100) : 0;
12721
12772
  const classesJustifyBetween = showDetails ? "justify-between" : "justify-center";
12722
12773
  return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
12723
12774
  "div",
@@ -12763,8 +12814,8 @@ var QuizResultPerformance = (0, import_react38.forwardRef)(({ showDetails = true
12763
12814
  className: "w-full",
12764
12815
  layout: "stacked",
12765
12816
  variant: "green",
12766
- value: correctEasyAnswers,
12767
- max: totalEasyQuestions,
12817
+ value: stats.correctEasyAnswers,
12818
+ max: stats.totalEasyQuestions,
12768
12819
  label: "F\xE1ceis",
12769
12820
  showHitCount: true,
12770
12821
  labelClassName: "text-base font-medium text-text-800 leading-none",
@@ -12777,8 +12828,8 @@ var QuizResultPerformance = (0, import_react38.forwardRef)(({ showDetails = true
12777
12828
  className: "w-full",
12778
12829
  layout: "stacked",
12779
12830
  variant: "green",
12780
- value: correctMediumAnswers,
12781
- max: totalMediumQuestions,
12831
+ value: stats.correctMediumAnswers,
12832
+ max: stats.totalMediumQuestions,
12782
12833
  label: "M\xE9dias",
12783
12834
  showHitCount: true,
12784
12835
  labelClassName: "text-base font-medium text-text-800 leading-none",
@@ -12791,8 +12842,8 @@ var QuizResultPerformance = (0, import_react38.forwardRef)(({ showDetails = true
12791
12842
  className: "w-full",
12792
12843
  layout: "stacked",
12793
12844
  variant: "green",
12794
- value: correctDifficultAnswers,
12795
- max: totalDifficultQuestions,
12845
+ value: stats.correctDifficultAnswers,
12846
+ max: stats.totalDifficultQuestions,
12796
12847
  label: "Dif\xEDceis",
12797
12848
  showHitCount: true,
12798
12849
  labelClassName: "text-base font-medium text-text-800 leading-none",
@@ -12812,13 +12863,13 @@ var QuizListResult = (0, import_react38.forwardRef)(({ className, onSubjectClick
12812
12863
  ([subjectId, questions]) => {
12813
12864
  let correct = 0;
12814
12865
  let incorrect = 0;
12815
- questions.forEach((question) => {
12816
- if (question.answerStatus == "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */) {
12866
+ for (const question of questions) {
12867
+ if (question.answerStatus === "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */) {
12817
12868
  correct++;
12818
12869
  } else {
12819
12870
  incorrect++;
12820
12871
  }
12821
- });
12872
+ }
12822
12873
  return {
12823
12874
  subject: {
12824
12875
  name: questions?.[0]?.knowledgeMatrix?.[0]?.subject?.name ?? "Sem mat\xE9ria",