analytica-frontend-lib 1.2.9 → 1.2.10
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/Quiz/index.js +38 -5
- package/dist/Quiz/index.js.map +1 -1
- package/dist/Quiz/index.mjs +38 -5
- package/dist/Quiz/index.mjs.map +1 -1
- package/dist/Quiz/useQuizStore/index.d.mts +3 -0
- package/dist/Quiz/useQuizStore/index.d.ts +3 -0
- package/dist/Quiz/useQuizStore/index.js +10 -2
- package/dist/Quiz/useQuizStore/index.js.map +1 -1
- package/dist/Quiz/useQuizStore/index.mjs +10 -2
- package/dist/Quiz/useQuizStore/index.mjs.map +1 -1
- package/dist/TextArea/index.d.mts +4 -0
- package/dist/TextArea/index.d.ts +4 -0
- package/dist/TextArea/index.js +22 -1
- package/dist/TextArea/index.js.map +1 -1
- package/dist/TextArea/index.mjs +22 -1
- package/dist/TextArea/index.mjs.map +1 -1
- package/dist/index.js +38 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/Quiz/index.js
CHANGED
|
@@ -1031,6 +1031,7 @@ var useQuizStore = (0, import_zustand2.create)()(
|
|
|
1031
1031
|
userId: "",
|
|
1032
1032
|
variant: "default",
|
|
1033
1033
|
minuteCallback: null,
|
|
1034
|
+
dissertativeCharLimit: void 0,
|
|
1034
1035
|
questionsResult: null,
|
|
1035
1036
|
currentQuestionResult: null,
|
|
1036
1037
|
// Setters
|
|
@@ -1040,6 +1041,8 @@ var useQuizStore = (0, import_zustand2.create)()(
|
|
|
1040
1041
|
getUserId: () => get().userId,
|
|
1041
1042
|
setVariant: (variant) => set({ variant }),
|
|
1042
1043
|
setQuestionResult: (questionsResult) => set({ questionsResult }),
|
|
1044
|
+
setDissertativeCharLimit: (limit) => set({ dissertativeCharLimit: limit }),
|
|
1045
|
+
getDissertativeCharLimit: () => get().dissertativeCharLimit,
|
|
1043
1046
|
// Navigation
|
|
1044
1047
|
goToNextQuestion: () => {
|
|
1045
1048
|
const { currentQuestionIndex, getTotalQuestions } = get();
|
|
@@ -1129,7 +1132,7 @@ var useQuizStore = (0, import_zustand2.create)()(
|
|
|
1129
1132
|
});
|
|
1130
1133
|
},
|
|
1131
1134
|
selectDissertativeAnswer: (questionId, answer) => {
|
|
1132
|
-
const { quiz, userAnswers } = get();
|
|
1135
|
+
const { quiz, userAnswers, dissertativeCharLimit } = get();
|
|
1133
1136
|
if (!quiz) return;
|
|
1134
1137
|
const activityId = quiz.id;
|
|
1135
1138
|
const userId = get().getUserId();
|
|
@@ -1140,6 +1143,10 @@ var useQuizStore = (0, import_zustand2.create)()(
|
|
|
1140
1143
|
if (!question || question.questionType !== "DISSERTATIVA" /* DISSERTATIVA */) {
|
|
1141
1144
|
return;
|
|
1142
1145
|
}
|
|
1146
|
+
let validatedAnswer = answer;
|
|
1147
|
+
if (dissertativeCharLimit !== void 0 && answer.length > dissertativeCharLimit) {
|
|
1148
|
+
validatedAnswer = answer.substring(0, dissertativeCharLimit);
|
|
1149
|
+
}
|
|
1143
1150
|
const existingAnswerIndex = userAnswers.findIndex(
|
|
1144
1151
|
(answerItem) => answerItem.questionId === questionId
|
|
1145
1152
|
);
|
|
@@ -1147,7 +1154,7 @@ var useQuizStore = (0, import_zustand2.create)()(
|
|
|
1147
1154
|
questionId,
|
|
1148
1155
|
activityId,
|
|
1149
1156
|
userId,
|
|
1150
|
-
answer,
|
|
1157
|
+
answer: validatedAnswer,
|
|
1151
1158
|
optionId: null,
|
|
1152
1159
|
questionType: "DISSERTATIVA" /* DISSERTATIVA */,
|
|
1153
1160
|
answerStatus: "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */
|
|
@@ -1260,6 +1267,7 @@ var useQuizStore = (0, import_zustand2.create)()(
|
|
|
1260
1267
|
userId: "",
|
|
1261
1268
|
variant: "default",
|
|
1262
1269
|
minuteCallback: null,
|
|
1270
|
+
dissertativeCharLimit: void 0,
|
|
1263
1271
|
questionsResult: null,
|
|
1264
1272
|
currentQuestionResult: null
|
|
1265
1273
|
});
|
|
@@ -2299,11 +2307,16 @@ var TextArea = (0, import_react7.forwardRef)(
|
|
|
2299
2307
|
onChange,
|
|
2300
2308
|
placeholder,
|
|
2301
2309
|
required,
|
|
2310
|
+
showCharacterCount = false,
|
|
2311
|
+
maxLength,
|
|
2312
|
+
value,
|
|
2302
2313
|
...props
|
|
2303
2314
|
}, ref) => {
|
|
2304
2315
|
const generatedId = (0, import_react7.useId)();
|
|
2305
2316
|
const inputId = id ?? `textarea-${generatedId}`;
|
|
2306
2317
|
const [isFocused, setIsFocused] = (0, import_react7.useState)(false);
|
|
2318
|
+
const currentLength = typeof value === "string" ? value.length : 0;
|
|
2319
|
+
const isNearLimit = maxLength && currentLength >= maxLength * 0.8;
|
|
2307
2320
|
const handleChange = (event) => {
|
|
2308
2321
|
onChange?.(event);
|
|
2309
2322
|
};
|
|
@@ -2358,6 +2371,8 @@ var TextArea = (0, import_react7.forwardRef)(
|
|
|
2358
2371
|
className: textareaClasses,
|
|
2359
2372
|
placeholder,
|
|
2360
2373
|
required,
|
|
2374
|
+
maxLength,
|
|
2375
|
+
value,
|
|
2361
2376
|
...props
|
|
2362
2377
|
}
|
|
2363
2378
|
),
|
|
@@ -2366,7 +2381,21 @@ var TextArea = (0, import_react7.forwardRef)(
|
|
|
2366
2381
|
" ",
|
|
2367
2382
|
errorMessage
|
|
2368
2383
|
] }),
|
|
2369
|
-
|
|
2384
|
+
!errorMessage && showCharacterCount && maxLength && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2385
|
+
Text_default,
|
|
2386
|
+
{
|
|
2387
|
+
size: "sm",
|
|
2388
|
+
weight: "normal",
|
|
2389
|
+
className: `mt-1.5 ${isNearLimit ? "text-indicator-warning" : "text-text-500"}`,
|
|
2390
|
+
children: [
|
|
2391
|
+
currentLength,
|
|
2392
|
+
"/",
|
|
2393
|
+
maxLength,
|
|
2394
|
+
" caracteres"
|
|
2395
|
+
]
|
|
2396
|
+
}
|
|
2397
|
+
),
|
|
2398
|
+
!errorMessage && helperMessage && !(showCharacterCount && maxLength) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text_default, { size: "sm", weight: "normal", className: "mt-1.5 text-text-500", children: helperMessage })
|
|
2370
2399
|
] });
|
|
2371
2400
|
}
|
|
2372
2401
|
);
|
|
@@ -3060,7 +3089,8 @@ var QuizDissertative = ({ paddingBottom }) => {
|
|
|
3060
3089
|
getCurrentAnswer,
|
|
3061
3090
|
selectDissertativeAnswer,
|
|
3062
3091
|
getQuestionResultByQuestionId,
|
|
3063
|
-
variant
|
|
3092
|
+
variant,
|
|
3093
|
+
getDissertativeCharLimit
|
|
3064
3094
|
} = useQuizStore();
|
|
3065
3095
|
const currentQuestion = getCurrentQuestion();
|
|
3066
3096
|
const currentQuestionResult = getQuestionResultByQuestionId(
|
|
@@ -3068,6 +3098,7 @@ var QuizDissertative = ({ paddingBottom }) => {
|
|
|
3068
3098
|
);
|
|
3069
3099
|
const currentAnswer = getCurrentAnswer();
|
|
3070
3100
|
const textareaRef = (0, import_react11.useRef)(null);
|
|
3101
|
+
const charLimit = getDissertativeCharLimit();
|
|
3071
3102
|
const handleAnswerChange = (value) => {
|
|
3072
3103
|
if (currentQuestion) {
|
|
3073
3104
|
selectDissertativeAnswer(currentQuestion.id, value);
|
|
@@ -3100,7 +3131,9 @@ var QuizDissertative = ({ paddingBottom }) => {
|
|
|
3100
3131
|
value: localAnswer,
|
|
3101
3132
|
onChange: (e) => handleAnswerChange(e.target.value),
|
|
3102
3133
|
rows: 4,
|
|
3103
|
-
className: "min-h-[120px] max-h-[400px] resize-none overflow-y-auto"
|
|
3134
|
+
className: "min-h-[120px] max-h-[400px] resize-none overflow-y-auto",
|
|
3135
|
+
maxLength: charLimit,
|
|
3136
|
+
showCharacterCount: !!charLimit
|
|
3104
3137
|
}
|
|
3105
3138
|
) }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "space-y-4", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-text-600 text-md whitespace-pre-wrap", children: localAnswer || "Nenhuma resposta fornecida" }) }) }) }),
|
|
3106
3139
|
variant === "result" && currentQuestionResult?.answerStatus == "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */ && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|