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.mjs CHANGED
@@ -8147,7 +8147,7 @@ var StatCard = ({ item, showPlaceholder = false }) => {
8147
8147
  {
8148
8148
  size: "xs",
8149
8149
  weight: "bold",
8150
- className: "uppercase text-[8px] leading-[9px] text-text-800 self-stretch",
8150
+ className: "uppercase text-[8px] leading-[9px] text-text-800 whitespace-nowrap",
8151
8151
  children: item.label
8152
8152
  }
8153
8153
  )
@@ -8183,8 +8183,18 @@ var StatisticsCard = ({
8183
8183
  className: `bg-background rounded-xl p-4 h-auto lg:h-[185px] flex flex-col gap-2 ${className}`,
8184
8184
  children: [
8185
8185
  /* @__PURE__ */ jsxs30("div", { className: "flex flex-row justify-between items-center gap-4", children: [
8186
- /* @__PURE__ */ jsx42(Text_default, { as: "h3", size: "sm", weight: "medium", color: "text-text-600", children: title }),
8187
- dropdownOptions && dropdownOptions.length > 0 && /* @__PURE__ */ jsx42("div", { className: "w-[99px]", children: /* @__PURE__ */ jsxs30(
8186
+ /* @__PURE__ */ jsx42(
8187
+ Text_default,
8188
+ {
8189
+ as: "h3",
8190
+ size: "sm",
8191
+ weight: "medium",
8192
+ color: "text-text-600",
8193
+ className: "flex-1 min-w-0",
8194
+ children: title
8195
+ }
8196
+ ),
8197
+ dropdownOptions && dropdownOptions.length > 0 && /* @__PURE__ */ jsx42("div", { className: "w-[120px] min-w-[90px] sm:shrink-0", children: /* @__PURE__ */ jsxs30(
8188
8198
  Select_default,
8189
8199
  {
8190
8200
  value: selectedDropdownValue,
@@ -8194,12 +8204,20 @@ var StatisticsCard = ({
8194
8204
  /* @__PURE__ */ jsx42(
8195
8205
  SelectTrigger,
8196
8206
  {
8197
- className: "border border-border-300 rounded whitespace-nowrap",
8207
+ className: "border border-border-300 rounded [&>span]:whitespace-nowrap [&>span]:overflow-hidden [&>span]:text-ellipsis",
8198
8208
  "aria-label": dropdownAriaLabel,
8199
8209
  children: /* @__PURE__ */ jsx42(SelectValue, { placeholder: selectPlaceholder })
8200
8210
  }
8201
8211
  ),
8202
- /* @__PURE__ */ jsx42(SelectContent, { children: dropdownOptions.map((option) => /* @__PURE__ */ jsx42(SelectItem, { value: option.value, children: option.label }, option.value)) })
8212
+ /* @__PURE__ */ jsx42(SelectContent, { className: "min-w-[120px]", children: dropdownOptions.map((option) => /* @__PURE__ */ jsx42(
8213
+ SelectItem,
8214
+ {
8215
+ value: option.value,
8216
+ className: "whitespace-nowrap",
8217
+ children: option.label
8218
+ },
8219
+ option.value
8220
+ )) })
8203
8221
  ]
8204
8222
  }
8205
8223
  ) })
@@ -11230,10 +11248,15 @@ var QuizAlternative = ({ paddingBottom }) => {
11230
11248
  const isSelected = currentQuestionResult?.selectedOptions.some(
11231
11249
  (selectedOption) => selectedOption.optionId === option.id
11232
11250
  );
11233
- if (isCorrectOption) {
11234
- status = "correct" /* CORRECT */;
11235
- } else if (isSelected && !isCorrectOption) {
11236
- status = "incorrect" /* INCORRECT */;
11251
+ const shouldShowCorrectAnswers = currentQuestionResult?.answerStatus !== "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */ && currentQuestionResult?.answerStatus !== "NAO_RESPONDIDO" /* NAO_RESPONDIDO */;
11252
+ if (shouldShowCorrectAnswers) {
11253
+ if (isCorrectOption) {
11254
+ status = "correct" /* CORRECT */;
11255
+ } else if (isSelected && !isCorrectOption) {
11256
+ status = "incorrect" /* INCORRECT */;
11257
+ } else {
11258
+ status = "neutral" /* NEUTRAL */;
11259
+ }
11237
11260
  } else {
11238
11261
  status = "neutral" /* NEUTRAL */;
11239
11262
  }
@@ -11331,10 +11354,15 @@ var QuizMultipleChoice = ({ paddingBottom }) => {
11331
11354
  const isSelected = currentQuestionResult?.selectedOptions?.some(
11332
11355
  (op) => op.optionId === option.id
11333
11356
  );
11334
- if (isCorrectOption) {
11335
- status = "correct" /* CORRECT */;
11336
- } else if (isSelected && !isCorrectOption) {
11337
- status = "incorrect" /* INCORRECT */;
11357
+ const shouldShowCorrectAnswers = currentQuestionResult?.answerStatus !== "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */ && currentQuestionResult?.answerStatus !== "NAO_RESPONDIDO" /* NAO_RESPONDIDO */;
11358
+ if (shouldShowCorrectAnswers) {
11359
+ if (isCorrectOption) {
11360
+ status = "correct" /* CORRECT */;
11361
+ } else if (isSelected && !isCorrectOption) {
11362
+ status = "incorrect" /* INCORRECT */;
11363
+ } else {
11364
+ status = "neutral" /* NEUTRAL */;
11365
+ }
11338
11366
  } else {
11339
11367
  status = "neutral" /* NEUTRAL */;
11340
11368
  }
@@ -11437,8 +11465,8 @@ var QuizTrueOrFalse = ({ paddingBottom }) => {
11437
11465
  isCorrect: false
11438
11466
  }
11439
11467
  ];
11440
- const getLetterByIndex = (index) => String.fromCharCode(97 + index);
11441
- const isDefaultVariant = variant == "default";
11468
+ const getLetterByIndex = (index) => String.fromCodePoint(97 + index);
11469
+ const isDefaultVariant = variant === "default";
11442
11470
  return /* @__PURE__ */ jsxs37(Fragment11, { children: [
11443
11471
  /* @__PURE__ */ jsx52(QuizSubTitle, { subTitle: "Alternativas" }),
11444
11472
  /* @__PURE__ */ jsx52(QuizContainer, { className: cn("", paddingBottom), children: /* @__PURE__ */ jsx52("div", { className: "flex flex-col gap-3.5", children: options.map((option, index) => {
@@ -11453,7 +11481,7 @@ var QuizTrueOrFalse = ({ paddingBottom }) => {
11453
11481
  {
11454
11482
  className: cn(
11455
11483
  "flex flex-row justify-between items-center gap-2 p-2 rounded-md",
11456
- !isDefaultVariant ? getStatusStyles(variantCorrect) : ""
11484
+ isDefaultVariant ? "" : getStatusStyles(variantCorrect)
11457
11485
  ),
11458
11486
  children: [
11459
11487
  /* @__PURE__ */ jsx52("p", { className: "text-text-900 text-sm", children: getLetterByIndex(index).concat(") ").concat(option.label) }),
@@ -11554,7 +11582,7 @@ var QuizConnectDots = ({ paddingBottom }) => {
11554
11582
  return next;
11555
11583
  });
11556
11584
  };
11557
- const getLetterByIndex = (index) => String.fromCharCode(97 + index);
11585
+ const getLetterByIndex = (index) => String.fromCodePoint(97 + index);
11558
11586
  const isDefaultVariant = variant === "default";
11559
11587
  const assignedDots = new Set(
11560
11588
  userAnswers.map((a) => a.dotOption).filter(Boolean)
@@ -11570,7 +11598,7 @@ var QuizConnectDots = ({ paddingBottom }) => {
11570
11598
  {
11571
11599
  className: cn(
11572
11600
  "flex flex-row justify-between items-center gap-2 p-2 rounded-md",
11573
- !isDefaultVariant ? getStatusStyles(variantCorrect) : ""
11601
+ isDefaultVariant ? "" : getStatusStyles(variantCorrect)
11574
11602
  ),
11575
11603
  children: [
11576
11604
  /* @__PURE__ */ jsx52("p", { className: "text-text-900 text-sm", children: getLetterByIndex(index) + ") " + option.label }),
@@ -11652,8 +11680,10 @@ var QuizFill = ({ paddingBottom }) => {
11652
11680
  const [answers, setAnswers] = useState21({});
11653
11681
  const baseId = useId11();
11654
11682
  const getAvailableOptionsForSelect = (selectId) => {
11655
- const usedOptions = Object.entries(answers).filter(([key]) => key !== selectId).map(([, value]) => value);
11656
- return options.filter((option) => !usedOptions.includes(option));
11683
+ const usedOptions = new Set(
11684
+ Object.entries(answers).filter(([key]) => key !== selectId).map(([, value]) => value)
11685
+ );
11686
+ return options.filter((option) => !usedOptions.has(option));
11657
11687
  };
11658
11688
  const handleSelectChange = (selectId, value) => {
11659
11689
  const newAnswers = { ...answers, [selectId]: value };
@@ -12538,7 +12568,11 @@ var QuizBadge = ({
12538
12568
  };
12539
12569
  var QuizHeaderResult = forwardRef23(
12540
12570
  ({ className, ...props }, ref) => {
12541
- const { getQuestionResultByQuestionId, getCurrentQuestion } = useQuizStore();
12571
+ const {
12572
+ getQuestionResultByQuestionId,
12573
+ getCurrentQuestion,
12574
+ questionsResult
12575
+ } = useQuizStore();
12542
12576
  const [status, setStatus] = useState23(void 0);
12543
12577
  useEffect23(() => {
12544
12578
  const cq = getCurrentQuestion();
@@ -12551,9 +12585,13 @@ var QuizHeaderResult = forwardRef23(
12551
12585
  }, [
12552
12586
  getCurrentQuestion,
12553
12587
  getQuestionResultByQuestionId,
12554
- getCurrentQuestion()?.id
12588
+ getCurrentQuestion()?.id,
12589
+ questionsResult
12555
12590
  ]);
12556
12591
  const getClassesByAnswersStatus = () => {
12592
+ if (status === void 0) {
12593
+ return "bg-gray-100";
12594
+ }
12557
12595
  switch (status) {
12558
12596
  case "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */:
12559
12597
  return "bg-success-background";
@@ -12566,6 +12604,9 @@ var QuizHeaderResult = forwardRef23(
12566
12604
  }
12567
12605
  };
12568
12606
  const getLabelByAnswersStatus = () => {
12607
+ if (status === void 0) {
12608
+ return "Carregando...";
12609
+ }
12569
12610
  switch (status) {
12570
12611
  case "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */:
12571
12612
  return "\u{1F389} Parab\xE9ns!!";
@@ -12574,6 +12615,7 @@ var QuizHeaderResult = forwardRef23(
12574
12615
  case "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */:
12575
12616
  return "Avalia\xE7\xE3o pendente";
12576
12617
  case "NAO_RESPONDIDO" /* NAO_RESPONDIDO */:
12618
+ return "N\xE3o foi dessa vez...voc\xEA deixou a resposta em branco";
12577
12619
  default:
12578
12620
  return "N\xE3o foi dessa vez...voc\xEA deixou a resposta em branco";
12579
12621
  }
@@ -12639,6 +12681,37 @@ var QuizResultTitle = forwardRef23(({ className, ...props }, ref) => {
12639
12681
  }
12640
12682
  );
12641
12683
  });
12684
+ var updateDifficultyStats = (stats, difficulty, isCorrect) => {
12685
+ if (difficulty === "FACIL" /* FACIL */) {
12686
+ stats.totalEasyQuestions++;
12687
+ if (isCorrect) stats.correctEasyAnswers++;
12688
+ } else if (difficulty === "MEDIO" /* MEDIO */) {
12689
+ stats.totalMediumQuestions++;
12690
+ if (isCorrect) stats.correctMediumAnswers++;
12691
+ } else if (difficulty === "DIFICIL" /* DIFICIL */) {
12692
+ stats.totalDifficultQuestions++;
12693
+ if (isCorrect) stats.correctDifficultAnswers++;
12694
+ }
12695
+ };
12696
+ var calculateAnswerStatistics = (answers) => {
12697
+ const stats = {
12698
+ correctAnswers: 0,
12699
+ correctEasyAnswers: 0,
12700
+ correctMediumAnswers: 0,
12701
+ correctDifficultAnswers: 0,
12702
+ totalEasyQuestions: 0,
12703
+ totalMediumQuestions: 0,
12704
+ totalDifficultQuestions: 0
12705
+ };
12706
+ for (const answer of answers) {
12707
+ const isCorrect = answer.answerStatus === "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */;
12708
+ if (isCorrect) {
12709
+ stats.correctAnswers++;
12710
+ }
12711
+ updateDifficultyStats(stats, answer.difficultyLevel, isCorrect);
12712
+ }
12713
+ return stats;
12714
+ };
12642
12715
  var QuizResultPerformance = forwardRef23(({ showDetails = true, ...props }, ref) => {
12643
12716
  const {
12644
12717
  getTotalQuestions,
@@ -12648,38 +12721,16 @@ var QuizResultPerformance = forwardRef23(({ showDetails = true, ...props }, ref)
12648
12721
  } = useQuizStore();
12649
12722
  const totalQuestions = getTotalQuestions();
12650
12723
  const questionResult = getQuestionResult();
12651
- let correctAnswers = 0;
12652
- let correctEasyAnswers = 0;
12653
- let correctMediumAnswers = 0;
12654
- let correctDifficultAnswers = 0;
12655
- let totalEasyQuestions = 0;
12656
- let totalMediumQuestions = 0;
12657
- let totalDifficultQuestions = 0;
12658
- if (questionResult) {
12659
- questionResult.answers.forEach((answer) => {
12660
- const isCorrect = answer.answerStatus == "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */;
12661
- if (isCorrect) {
12662
- correctAnswers++;
12663
- }
12664
- if (answer.difficultyLevel === "FACIL" /* FACIL */) {
12665
- totalEasyQuestions++;
12666
- if (isCorrect) {
12667
- correctEasyAnswers++;
12668
- }
12669
- } else if (answer.difficultyLevel === "MEDIO" /* MEDIO */) {
12670
- totalMediumQuestions++;
12671
- if (isCorrect) {
12672
- correctMediumAnswers++;
12673
- }
12674
- } else if (answer.difficultyLevel === "DIFICIL" /* DIFICIL */) {
12675
- totalDifficultQuestions++;
12676
- if (isCorrect) {
12677
- correctDifficultAnswers++;
12678
- }
12679
- }
12680
- });
12681
- }
12682
- const percentage = totalQuestions > 0 ? Math.round(correctAnswers / totalQuestions * 100) : 0;
12724
+ const stats = questionResult ? calculateAnswerStatistics(questionResult.answers) : {
12725
+ correctAnswers: 0,
12726
+ correctEasyAnswers: 0,
12727
+ correctMediumAnswers: 0,
12728
+ correctDifficultAnswers: 0,
12729
+ totalEasyQuestions: 0,
12730
+ totalMediumQuestions: 0,
12731
+ totalDifficultQuestions: 0
12732
+ };
12733
+ const percentage = totalQuestions > 0 ? Math.round(stats.correctAnswers / totalQuestions * 100) : 0;
12683
12734
  const classesJustifyBetween = showDetails ? "justify-between" : "justify-center";
12684
12735
  return /* @__PURE__ */ jsxs39(
12685
12736
  "div",
@@ -12725,8 +12776,8 @@ var QuizResultPerformance = forwardRef23(({ showDetails = true, ...props }, ref)
12725
12776
  className: "w-full",
12726
12777
  layout: "stacked",
12727
12778
  variant: "green",
12728
- value: correctEasyAnswers,
12729
- max: totalEasyQuestions,
12779
+ value: stats.correctEasyAnswers,
12780
+ max: stats.totalEasyQuestions,
12730
12781
  label: "F\xE1ceis",
12731
12782
  showHitCount: true,
12732
12783
  labelClassName: "text-base font-medium text-text-800 leading-none",
@@ -12739,8 +12790,8 @@ var QuizResultPerformance = forwardRef23(({ showDetails = true, ...props }, ref)
12739
12790
  className: "w-full",
12740
12791
  layout: "stacked",
12741
12792
  variant: "green",
12742
- value: correctMediumAnswers,
12743
- max: totalMediumQuestions,
12793
+ value: stats.correctMediumAnswers,
12794
+ max: stats.totalMediumQuestions,
12744
12795
  label: "M\xE9dias",
12745
12796
  showHitCount: true,
12746
12797
  labelClassName: "text-base font-medium text-text-800 leading-none",
@@ -12753,8 +12804,8 @@ var QuizResultPerformance = forwardRef23(({ showDetails = true, ...props }, ref)
12753
12804
  className: "w-full",
12754
12805
  layout: "stacked",
12755
12806
  variant: "green",
12756
- value: correctDifficultAnswers,
12757
- max: totalDifficultQuestions,
12807
+ value: stats.correctDifficultAnswers,
12808
+ max: stats.totalDifficultQuestions,
12758
12809
  label: "Dif\xEDceis",
12759
12810
  showHitCount: true,
12760
12811
  labelClassName: "text-base font-medium text-text-800 leading-none",
@@ -12774,13 +12825,13 @@ var QuizListResult = forwardRef23(({ className, onSubjectClick, ...props }, ref)
12774
12825
  ([subjectId, questions]) => {
12775
12826
  let correct = 0;
12776
12827
  let incorrect = 0;
12777
- questions.forEach((question) => {
12778
- if (question.answerStatus == "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */) {
12828
+ for (const question of questions) {
12829
+ if (question.answerStatus === "RESPOSTA_CORRETA" /* RESPOSTA_CORRETA */) {
12779
12830
  correct++;
12780
12831
  } else {
12781
12832
  incorrect++;
12782
12833
  }
12783
- });
12834
+ }
12784
12835
  return {
12785
12836
  subject: {
12786
12837
  name: questions?.[0]?.knowledgeMatrix?.[0]?.subject?.name ?? "Sem mat\xE9ria",