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.
package/dist/index.mjs CHANGED
@@ -7562,6 +7562,9 @@ var useQuizStore = create7()(
7562
7562
  // src/assets/img/simulated-result.png
7563
7563
  var simulated_result_default = "./simulated-result-QN5HCUY5.png";
7564
7564
 
7565
+ // src/assets/img/mock-image-question.png
7566
+ var mock_image_question_default = "./mock-image-question-HEZCLFDL.png";
7567
+
7565
7568
  // src/components/Quiz/Quiz.tsx
7566
7569
  import { Fragment as Fragment8, jsx as jsx37, jsxs as jsxs30 } from "react/jsx-runtime";
7567
7570
  var getStatusBadge = (status) => {
@@ -7700,7 +7703,8 @@ var QuizContent = forwardRef19(({ variant, paddingBottom }) => {
7700
7703
  ["DISSERTATIVA" /* DISSERTATIVA */]: QuizDissertative,
7701
7704
  ["VERDADEIRO_FALSO" /* VERDADEIRO_FALSO */]: QuizTrueOrFalse,
7702
7705
  ["LIGAR_PONTOS" /* LIGAR_PONTOS */]: QuizConnectDots,
7703
- ["PREENCHER" /* PREENCHER */]: QuizFill
7706
+ ["PREENCHER" /* PREENCHER */]: QuizFill,
7707
+ ["IMAGEM" /* IMAGEM */]: QuizImageQuestion
7704
7708
  };
7705
7709
  const QuestionComponent = currentQuestion ? questionComponents[currentQuestion.type] : null;
7706
7710
  return QuestionComponent ? /* @__PURE__ */ jsx37(QuestionComponent, { variant, paddingBottom }) : null;
@@ -8240,6 +8244,147 @@ var QuizFill = ({
8240
8244
  ] })
8241
8245
  ] });
8242
8246
  };
8247
+ var QuizImageQuestion = ({
8248
+ variant = "default",
8249
+ paddingBottom
8250
+ }) => {
8251
+ const correctPositionRelative = { x: 0.48, y: 0.45 };
8252
+ const calculateCorrectRadiusRelative = () => {
8253
+ const circleWidthRelative = 0.15;
8254
+ const circleHeightRelative = 0.3;
8255
+ const averageRadius = (circleWidthRelative + circleHeightRelative) / 4;
8256
+ const tolerance = 0.02;
8257
+ return averageRadius + tolerance;
8258
+ };
8259
+ const correctRadiusRelative = calculateCorrectRadiusRelative();
8260
+ const mockUserAnswerRelative = { x: 0.72, y: 0.348 };
8261
+ const [clickPositionRelative, setClickPositionRelative] = useState14(variant == "result" ? mockUserAnswerRelative : null);
8262
+ const convertToRelativeCoordinates = (x, y, rect) => {
8263
+ const safeWidth = Math.max(rect.width, 1e-3);
8264
+ const safeHeight = Math.max(rect.height, 1e-3);
8265
+ const xRelative = Math.max(0, Math.min(1, x / safeWidth));
8266
+ const yRelative = Math.max(0, Math.min(1, y / safeHeight));
8267
+ return { x: xRelative, y: yRelative };
8268
+ };
8269
+ const handleImageClick = (event) => {
8270
+ if (variant === "result") return;
8271
+ const rect = event.currentTarget.getBoundingClientRect();
8272
+ const x = event.clientX - rect.left;
8273
+ const y = event.clientY - rect.top;
8274
+ const positionRelative = convertToRelativeCoordinates(x, y, rect);
8275
+ setClickPositionRelative(positionRelative);
8276
+ };
8277
+ const handleKeyboardActivate = () => {
8278
+ if (variant === "result") return;
8279
+ setClickPositionRelative({ x: 0.5, y: 0.5 });
8280
+ };
8281
+ const isCorrect = () => {
8282
+ if (!clickPositionRelative) return false;
8283
+ const distance = Math.sqrt(
8284
+ Math.pow(clickPositionRelative.x - correctPositionRelative.x, 2) + Math.pow(clickPositionRelative.y - correctPositionRelative.y, 2)
8285
+ );
8286
+ return distance <= correctRadiusRelative;
8287
+ };
8288
+ const getUserCircleColorClasses = () => {
8289
+ if (variant === "default") {
8290
+ return "bg-indicator-primary/70 border-[#F8CC2E]";
8291
+ }
8292
+ if (variant === "result") {
8293
+ return isCorrect() ? "bg-success-600/70 border-white" : "bg-indicator-error/70 border-white";
8294
+ }
8295
+ return "bg-success-600/70 border-white";
8296
+ };
8297
+ return /* @__PURE__ */ jsxs30(Fragment8, { children: [
8298
+ /* @__PURE__ */ jsx37(QuizSubTitle, { subTitle: "Clique na \xE1rea correta" }),
8299
+ /* @__PURE__ */ jsx37(QuizContainer, { className: cn("", paddingBottom), children: /* @__PURE__ */ jsxs30(
8300
+ "div",
8301
+ {
8302
+ "data-testid": "quiz-image-container",
8303
+ className: "space-y-6 p-3 relative inline-block",
8304
+ children: [
8305
+ variant == "result" && /* @__PURE__ */ jsxs30(
8306
+ "div",
8307
+ {
8308
+ "data-testid": "quiz-legend",
8309
+ className: "flex items-center gap-4 text-xs",
8310
+ children: [
8311
+ /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-2", children: [
8312
+ /* @__PURE__ */ jsx37("div", { className: "w-3 h-3 rounded-full bg-indicator-primary/70 border border-[#F8CC2E]" }),
8313
+ /* @__PURE__ */ jsx37("span", { className: "text-text-600 font-medium text-sm", children: "\xC1rea correta" })
8314
+ ] }),
8315
+ /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-2", children: [
8316
+ /* @__PURE__ */ jsx37("div", { className: "w-3 h-3 rounded-full bg-success-600/70 border border-white" }),
8317
+ /* @__PURE__ */ jsx37("span", { className: "text-text-600 font-medium text-sm", children: "Resposta correta" })
8318
+ ] }),
8319
+ /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-2", children: [
8320
+ /* @__PURE__ */ jsx37("div", { className: "w-3 h-3 rounded-full bg-indicator-error/70 border border-white" }),
8321
+ /* @__PURE__ */ jsx37("span", { className: "text-text-600 font-medium text-sm", children: "Resposta incorreta" })
8322
+ ] })
8323
+ ]
8324
+ }
8325
+ ),
8326
+ /* @__PURE__ */ jsxs30(
8327
+ "button",
8328
+ {
8329
+ "data-testid": "quiz-image-button",
8330
+ type: "button",
8331
+ className: "relative cursor-pointer w-full h-full border-0 bg-transparent p-0",
8332
+ onClick: handleImageClick,
8333
+ onKeyDown: (e) => {
8334
+ if (e.key === "Enter" || e.key === " ") {
8335
+ e.preventDefault();
8336
+ handleKeyboardActivate();
8337
+ }
8338
+ },
8339
+ "aria-label": "\xC1rea da imagem interativa",
8340
+ children: [
8341
+ /* @__PURE__ */ jsx37(
8342
+ "img",
8343
+ {
8344
+ "data-testid": "quiz-image",
8345
+ src: mock_image_question_default,
8346
+ alt: "Question",
8347
+ className: "w-full h-auto rounded-md"
8348
+ }
8349
+ ),
8350
+ variant === "result" && /* @__PURE__ */ jsx37(
8351
+ "div",
8352
+ {
8353
+ "data-testid": "quiz-correct-circle",
8354
+ className: "absolute rounded-full bg-indicator-primary/70 border-4 border-[#F8CC2E] pointer-events-none",
8355
+ style: {
8356
+ minWidth: "50px",
8357
+ maxWidth: "160px",
8358
+ width: "15%",
8359
+ aspectRatio: "1 / 1",
8360
+ left: `calc(${correctPositionRelative.x * 100}% - 7.5%)`,
8361
+ top: `calc(${correctPositionRelative.y * 100}% - 15%)`
8362
+ }
8363
+ }
8364
+ ),
8365
+ clickPositionRelative && /* @__PURE__ */ jsx37(
8366
+ "div",
8367
+ {
8368
+ "data-testid": "quiz-user-circle",
8369
+ className: `absolute rounded-full border-4 pointer-events-none ${getUserCircleColorClasses()}`,
8370
+ style: {
8371
+ minWidth: "30px",
8372
+ maxWidth: "52px",
8373
+ width: "5%",
8374
+ aspectRatio: "1 / 1",
8375
+ left: `calc(${clickPositionRelative.x * 100}% - 2.5%)`,
8376
+ top: `calc(${clickPositionRelative.y * 100}% - 2.5%)`
8377
+ }
8378
+ }
8379
+ )
8380
+ ]
8381
+ }
8382
+ )
8383
+ ]
8384
+ }
8385
+ ) })
8386
+ ] });
8387
+ };
8243
8388
  var QuizQuestionList = ({
8244
8389
  filterType = "all",
8245
8390
  onQuestionClick
@@ -8321,6 +8466,7 @@ var QuizFooter = forwardRef19(
8321
8466
  className,
8322
8467
  onGoToSimulated,
8323
8468
  onDetailResult,
8469
+ handleFinishSimulated,
8324
8470
  variant = "default",
8325
8471
  ...props
8326
8472
  }, ref) => {
@@ -8350,6 +8496,34 @@ var QuizFooter = forwardRef19(
8350
8496
  const unansweredQuestions = getUnansweredQuestionsFromUserAnswers();
8351
8497
  const userAnswers = getUserAnswers();
8352
8498
  const allQuestions = getTotalQuestions();
8499
+ const handleFinishQuiz = async () => {
8500
+ if (unansweredQuestions.length > 0) {
8501
+ setAlertDialogOpen(true);
8502
+ return;
8503
+ }
8504
+ try {
8505
+ if (handleFinishSimulated) {
8506
+ await Promise.resolve(handleFinishSimulated());
8507
+ }
8508
+ setModalResultOpen(true);
8509
+ } catch (err) {
8510
+ console.error("handleFinishSimulated failed:", err);
8511
+ setModalResultOpen(true);
8512
+ }
8513
+ };
8514
+ const handleAlertSubmit = async () => {
8515
+ try {
8516
+ if (handleFinishSimulated) {
8517
+ await Promise.resolve(handleFinishSimulated());
8518
+ }
8519
+ setModalResultOpen(true);
8520
+ setAlertDialogOpen(false);
8521
+ } catch (err) {
8522
+ console.error("handleFinishSimulated failed:", err);
8523
+ setModalResultOpen(true);
8524
+ setAlertDialogOpen(false);
8525
+ }
8526
+ };
8353
8527
  return /* @__PURE__ */ jsxs30(Fragment8, { children: [
8354
8528
  /* @__PURE__ */ jsx37(
8355
8529
  "footer",
@@ -8415,13 +8589,7 @@ var QuizFooter = forwardRef19(
8415
8589
  variant: "solid",
8416
8590
  action: "primary",
8417
8591
  disabled: !currentAnswer && !isCurrentQuestionSkipped,
8418
- onClick: () => {
8419
- if (unansweredQuestions.length > 0) {
8420
- setAlertDialogOpen(true);
8421
- } else {
8422
- setModalResultOpen(true);
8423
- }
8424
- },
8592
+ onClick: handleFinishQuiz,
8425
8593
  children: "Finalizar"
8426
8594
  }
8427
8595
  ) : /* @__PURE__ */ jsx37(
@@ -8450,9 +8618,7 @@ var QuizFooter = forwardRef19(
8450
8618
  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?",
8451
8619
  cancelButtonLabel: "Voltar e revisar",
8452
8620
  submitButtonLabel: "Finalizar Mesmo Assim",
8453
- onSubmit: () => {
8454
- setModalResultOpen(true);
8455
- }
8621
+ onSubmit: handleAlertSubmit
8456
8622
  }
8457
8623
  ),
8458
8624
  /* @__PURE__ */ jsx37(
@@ -8836,6 +9002,7 @@ export {
8836
9002
  QuizFooter,
8837
9003
  QuizHeader,
8838
9004
  QuizHeaderResult,
9005
+ QuizImageQuestion,
8839
9006
  QuizListResult,
8840
9007
  QuizListResultByMateria,
8841
9008
  QuizMultipleChoice,