analytica-frontend-lib 1.0.97 → 1.0.99

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) => {
@@ -7666,12 +7669,12 @@ var QuizSubTitle = forwardRef19(
7666
7669
  }
7667
7670
  );
7668
7671
  var QuizHeader = () => {
7669
- const { getCurrentQuestion } = useQuizStore();
7672
+ const { getCurrentQuestion, currentQuestionIndex } = useQuizStore();
7670
7673
  const currentQuestion = getCurrentQuestion();
7671
7674
  return /* @__PURE__ */ jsx37(
7672
7675
  HeaderAlternative,
7673
7676
  {
7674
- title: currentQuestion ? `Quest\xE3o ${currentQuestion.id}` : "Quest\xE3o",
7677
+ title: currentQuestion ? `Quest\xE3o ${currentQuestionIndex + 1}` : "Quest\xE3o",
7675
7678
  subTitle: currentQuestion?.knowledgeMatrix?.[0]?.topicId ?? "",
7676
7679
  content: currentQuestion?.questionText ?? ""
7677
7680
  }
@@ -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
@@ -8836,6 +8981,7 @@ export {
8836
8981
  QuizFooter,
8837
8982
  QuizHeader,
8838
8983
  QuizHeaderResult,
8984
+ QuizImageQuestion,
8839
8985
  QuizListResult,
8840
8986
  QuizListResultByMateria,
8841
8987
  QuizMultipleChoice,