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.
@@ -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) => {
@@ -4598,12 +4601,12 @@ var QuizSubTitle = forwardRef10(
4598
4601
  }
4599
4602
  );
4600
4603
  var QuizHeader = () => {
4601
- const { getCurrentQuestion } = useQuizStore();
4604
+ const { getCurrentQuestion, currentQuestionIndex } = useQuizStore();
4602
4605
  const currentQuestion = getCurrentQuestion();
4603
4606
  return /* @__PURE__ */ jsx17(
4604
4607
  HeaderAlternative,
4605
4608
  {
4606
- title: currentQuestion ? `Quest\xE3o ${currentQuestion.id}` : "Quest\xE3o",
4609
+ title: currentQuestion ? `Quest\xE3o ${currentQuestionIndex + 1}` : "Quest\xE3o",
4607
4610
  subTitle: currentQuestion?.knowledgeMatrix?.[0]?.topicId ?? "",
4608
4611
  content: currentQuestion?.questionText ?? ""
4609
4612
  }
@@ -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
@@ -5720,6 +5865,7 @@ export {
5720
5865
  QuizFooter,
5721
5866
  QuizHeader,
5722
5867
  QuizHeaderResult,
5868
+ QuizImageQuestion,
5723
5869
  QuizListResult,
5724
5870
  QuizListResultByMateria,
5725
5871
  QuizMultipleChoice,