analytica-frontend-lib 1.0.98 → 1.1.0

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.
@@ -4494,6 +4494,9 @@ var TextArea = forwardRef9(
4494
4494
  TextArea.displayName = "TextArea";
4495
4495
  var TextArea_default = TextArea;
4496
4496
 
4497
+ // src/assets/img/mock-image-question.png
4498
+ var mock_image_question_default = "../mock-image-question-HEZCLFDL.png";
4499
+
4497
4500
  // src/components/Quiz/Quiz.tsx
4498
4501
  import { Fragment as Fragment6, jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
4499
4502
  var getStatusBadge = (status) => {
@@ -4632,7 +4635,8 @@ var QuizContent = forwardRef10(({ variant, paddingBottom }) => {
4632
4635
  ["DISSERTATIVA" /* DISSERTATIVA */]: QuizDissertative,
4633
4636
  ["VERDADEIRO_FALSO" /* VERDADEIRO_FALSO */]: QuizTrueOrFalse,
4634
4637
  ["LIGAR_PONTOS" /* LIGAR_PONTOS */]: QuizConnectDots,
4635
- ["PREENCHER" /* PREENCHER */]: QuizFill
4638
+ ["PREENCHER" /* PREENCHER */]: QuizFill,
4639
+ ["IMAGEM" /* IMAGEM */]: QuizImageQuestion
4636
4640
  };
4637
4641
  const QuestionComponent = currentQuestion ? questionComponents[currentQuestion.type] : null;
4638
4642
  return QuestionComponent ? /* @__PURE__ */ jsx17(QuestionComponent, { variant, paddingBottom }) : null;
@@ -5172,6 +5176,147 @@ var QuizFill = ({
5172
5176
  ] })
5173
5177
  ] });
5174
5178
  };
5179
+ var QuizImageQuestion = ({
5180
+ variant = "default",
5181
+ paddingBottom
5182
+ }) => {
5183
+ const correctPositionRelative = { x: 0.48, y: 0.45 };
5184
+ const calculateCorrectRadiusRelative = () => {
5185
+ const circleWidthRelative = 0.15;
5186
+ const circleHeightRelative = 0.3;
5187
+ const averageRadius = (circleWidthRelative + circleHeightRelative) / 4;
5188
+ const tolerance = 0.02;
5189
+ return averageRadius + tolerance;
5190
+ };
5191
+ const correctRadiusRelative = calculateCorrectRadiusRelative();
5192
+ const mockUserAnswerRelative = { x: 0.72, y: 0.348 };
5193
+ const [clickPositionRelative, setClickPositionRelative] = useState7(variant == "result" ? mockUserAnswerRelative : null);
5194
+ const convertToRelativeCoordinates = (x, y, rect) => {
5195
+ const safeWidth = Math.max(rect.width, 1e-3);
5196
+ const safeHeight = Math.max(rect.height, 1e-3);
5197
+ const xRelative = Math.max(0, Math.min(1, x / safeWidth));
5198
+ const yRelative = Math.max(0, Math.min(1, y / safeHeight));
5199
+ return { x: xRelative, y: yRelative };
5200
+ };
5201
+ const handleImageClick = (event) => {
5202
+ if (variant === "result") return;
5203
+ const rect = event.currentTarget.getBoundingClientRect();
5204
+ const x = event.clientX - rect.left;
5205
+ const y = event.clientY - rect.top;
5206
+ const positionRelative = convertToRelativeCoordinates(x, y, rect);
5207
+ setClickPositionRelative(positionRelative);
5208
+ };
5209
+ const handleKeyboardActivate = () => {
5210
+ if (variant === "result") return;
5211
+ setClickPositionRelative({ x: 0.5, y: 0.5 });
5212
+ };
5213
+ const isCorrect = () => {
5214
+ if (!clickPositionRelative) return false;
5215
+ const distance = Math.sqrt(
5216
+ Math.pow(clickPositionRelative.x - correctPositionRelative.x, 2) + Math.pow(clickPositionRelative.y - correctPositionRelative.y, 2)
5217
+ );
5218
+ return distance <= correctRadiusRelative;
5219
+ };
5220
+ const getUserCircleColorClasses = () => {
5221
+ if (variant === "default") {
5222
+ return "bg-indicator-primary/70 border-[#F8CC2E]";
5223
+ }
5224
+ if (variant === "result") {
5225
+ return isCorrect() ? "bg-success-600/70 border-white" : "bg-indicator-error/70 border-white";
5226
+ }
5227
+ return "bg-success-600/70 border-white";
5228
+ };
5229
+ return /* @__PURE__ */ jsxs14(Fragment6, { children: [
5230
+ /* @__PURE__ */ jsx17(QuizSubTitle, { subTitle: "Clique na \xE1rea correta" }),
5231
+ /* @__PURE__ */ jsx17(QuizContainer, { className: cn("", paddingBottom), children: /* @__PURE__ */ jsxs14(
5232
+ "div",
5233
+ {
5234
+ "data-testid": "quiz-image-container",
5235
+ className: "space-y-6 p-3 relative inline-block",
5236
+ children: [
5237
+ variant == "result" && /* @__PURE__ */ jsxs14(
5238
+ "div",
5239
+ {
5240
+ "data-testid": "quiz-legend",
5241
+ className: "flex items-center gap-4 text-xs",
5242
+ children: [
5243
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
5244
+ /* @__PURE__ */ jsx17("div", { className: "w-3 h-3 rounded-full bg-indicator-primary/70 border border-[#F8CC2E]" }),
5245
+ /* @__PURE__ */ jsx17("span", { className: "text-text-600 font-medium text-sm", children: "\xC1rea correta" })
5246
+ ] }),
5247
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
5248
+ /* @__PURE__ */ jsx17("div", { className: "w-3 h-3 rounded-full bg-success-600/70 border border-white" }),
5249
+ /* @__PURE__ */ jsx17("span", { className: "text-text-600 font-medium text-sm", children: "Resposta correta" })
5250
+ ] }),
5251
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
5252
+ /* @__PURE__ */ jsx17("div", { className: "w-3 h-3 rounded-full bg-indicator-error/70 border border-white" }),
5253
+ /* @__PURE__ */ jsx17("span", { className: "text-text-600 font-medium text-sm", children: "Resposta incorreta" })
5254
+ ] })
5255
+ ]
5256
+ }
5257
+ ),
5258
+ /* @__PURE__ */ jsxs14(
5259
+ "button",
5260
+ {
5261
+ "data-testid": "quiz-image-button",
5262
+ type: "button",
5263
+ className: "relative cursor-pointer w-full h-full border-0 bg-transparent p-0",
5264
+ onClick: handleImageClick,
5265
+ onKeyDown: (e) => {
5266
+ if (e.key === "Enter" || e.key === " ") {
5267
+ e.preventDefault();
5268
+ handleKeyboardActivate();
5269
+ }
5270
+ },
5271
+ "aria-label": "\xC1rea da imagem interativa",
5272
+ children: [
5273
+ /* @__PURE__ */ jsx17(
5274
+ "img",
5275
+ {
5276
+ "data-testid": "quiz-image",
5277
+ src: mock_image_question_default,
5278
+ alt: "Question",
5279
+ className: "w-full h-auto rounded-md"
5280
+ }
5281
+ ),
5282
+ variant === "result" && /* @__PURE__ */ jsx17(
5283
+ "div",
5284
+ {
5285
+ "data-testid": "quiz-correct-circle",
5286
+ className: "absolute rounded-full bg-indicator-primary/70 border-4 border-[#F8CC2E] pointer-events-none",
5287
+ style: {
5288
+ minWidth: "50px",
5289
+ maxWidth: "160px",
5290
+ width: "15%",
5291
+ aspectRatio: "1 / 1",
5292
+ left: `calc(${correctPositionRelative.x * 100}% - 7.5%)`,
5293
+ top: `calc(${correctPositionRelative.y * 100}% - 15%)`
5294
+ }
5295
+ }
5296
+ ),
5297
+ clickPositionRelative && /* @__PURE__ */ jsx17(
5298
+ "div",
5299
+ {
5300
+ "data-testid": "quiz-user-circle",
5301
+ className: `absolute rounded-full border-4 pointer-events-none ${getUserCircleColorClasses()}`,
5302
+ style: {
5303
+ minWidth: "30px",
5304
+ maxWidth: "52px",
5305
+ width: "5%",
5306
+ aspectRatio: "1 / 1",
5307
+ left: `calc(${clickPositionRelative.x * 100}% - 2.5%)`,
5308
+ top: `calc(${clickPositionRelative.y * 100}% - 2.5%)`
5309
+ }
5310
+ }
5311
+ )
5312
+ ]
5313
+ }
5314
+ )
5315
+ ]
5316
+ }
5317
+ ) })
5318
+ ] });
5319
+ };
5175
5320
  var QuizQuestionList = ({
5176
5321
  filterType = "all",
5177
5322
  onQuestionClick
@@ -5253,6 +5398,7 @@ var QuizFooter = forwardRef10(
5253
5398
  className,
5254
5399
  onGoToSimulated,
5255
5400
  onDetailResult,
5401
+ handleFinishSimulated,
5256
5402
  variant = "default",
5257
5403
  ...props
5258
5404
  }, ref) => {
@@ -5282,6 +5428,34 @@ var QuizFooter = forwardRef10(
5282
5428
  const unansweredQuestions = getUnansweredQuestionsFromUserAnswers();
5283
5429
  const userAnswers = getUserAnswers();
5284
5430
  const allQuestions = getTotalQuestions();
5431
+ const handleFinishQuiz = async () => {
5432
+ if (unansweredQuestions.length > 0) {
5433
+ setAlertDialogOpen(true);
5434
+ return;
5435
+ }
5436
+ try {
5437
+ if (handleFinishSimulated) {
5438
+ await Promise.resolve(handleFinishSimulated());
5439
+ }
5440
+ setModalResultOpen(true);
5441
+ } catch (err) {
5442
+ console.error("handleFinishSimulated failed:", err);
5443
+ setModalResultOpen(true);
5444
+ }
5445
+ };
5446
+ const handleAlertSubmit = async () => {
5447
+ try {
5448
+ if (handleFinishSimulated) {
5449
+ await Promise.resolve(handleFinishSimulated());
5450
+ }
5451
+ setModalResultOpen(true);
5452
+ setAlertDialogOpen(false);
5453
+ } catch (err) {
5454
+ console.error("handleFinishSimulated failed:", err);
5455
+ setModalResultOpen(true);
5456
+ setAlertDialogOpen(false);
5457
+ }
5458
+ };
5285
5459
  return /* @__PURE__ */ jsxs14(Fragment6, { children: [
5286
5460
  /* @__PURE__ */ jsx17(
5287
5461
  "footer",
@@ -5347,13 +5521,7 @@ var QuizFooter = forwardRef10(
5347
5521
  variant: "solid",
5348
5522
  action: "primary",
5349
5523
  disabled: !currentAnswer && !isCurrentQuestionSkipped,
5350
- onClick: () => {
5351
- if (unansweredQuestions.length > 0) {
5352
- setAlertDialogOpen(true);
5353
- } else {
5354
- setModalResultOpen(true);
5355
- }
5356
- },
5524
+ onClick: handleFinishQuiz,
5357
5525
  children: "Finalizar"
5358
5526
  }
5359
5527
  ) : /* @__PURE__ */ jsx17(
@@ -5382,9 +5550,7 @@ var QuizFooter = forwardRef10(
5382
5550
  description: unansweredQuestions.length > 0 ? `Voc\xEA deixou as quest\xF5es ${unansweredQuestions.join(", ")} sem resposta. Finalizar agora pode impactar seu desempenho.` : "Tem certeza que deseja finalizar o simulado?",
5383
5551
  cancelButtonLabel: "Voltar e revisar",
5384
5552
  submitButtonLabel: "Finalizar Mesmo Assim",
5385
- onSubmit: () => {
5386
- setModalResultOpen(true);
5387
- }
5553
+ onSubmit: handleAlertSubmit
5388
5554
  }
5389
5555
  ),
5390
5556
  /* @__PURE__ */ jsx17(
@@ -5720,6 +5886,7 @@ export {
5720
5886
  QuizFooter,
5721
5887
  QuizHeader,
5722
5888
  QuizHeaderResult,
5889
+ QuizImageQuestion,
5723
5890
  QuizListResult,
5724
5891
  QuizListResultByMateria,
5725
5892
  QuizMultipleChoice,