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/index.mjs
CHANGED
|
@@ -1864,11 +1864,16 @@ var TextArea = forwardRef7(
|
|
|
1864
1864
|
onChange,
|
|
1865
1865
|
placeholder,
|
|
1866
1866
|
required,
|
|
1867
|
+
showCharacterCount = false,
|
|
1868
|
+
maxLength,
|
|
1869
|
+
value,
|
|
1867
1870
|
...props
|
|
1868
1871
|
}, ref) => {
|
|
1869
1872
|
const generatedId = useId4();
|
|
1870
1873
|
const inputId = id ?? `textarea-${generatedId}`;
|
|
1871
1874
|
const [isFocused, setIsFocused] = useState5(false);
|
|
1875
|
+
const currentLength = typeof value === "string" ? value.length : 0;
|
|
1876
|
+
const isNearLimit = maxLength && currentLength >= maxLength * 0.8;
|
|
1872
1877
|
const handleChange = (event) => {
|
|
1873
1878
|
onChange?.(event);
|
|
1874
1879
|
};
|
|
@@ -1923,6 +1928,8 @@ var TextArea = forwardRef7(
|
|
|
1923
1928
|
className: textareaClasses,
|
|
1924
1929
|
placeholder,
|
|
1925
1930
|
required,
|
|
1931
|
+
maxLength,
|
|
1932
|
+
value,
|
|
1926
1933
|
...props
|
|
1927
1934
|
}
|
|
1928
1935
|
),
|
|
@@ -1931,7 +1938,21 @@ var TextArea = forwardRef7(
|
|
|
1931
1938
|
" ",
|
|
1932
1939
|
errorMessage
|
|
1933
1940
|
] }),
|
|
1934
|
-
|
|
1941
|
+
!errorMessage && showCharacterCount && maxLength && /* @__PURE__ */ jsxs10(
|
|
1942
|
+
Text_default,
|
|
1943
|
+
{
|
|
1944
|
+
size: "sm",
|
|
1945
|
+
weight: "normal",
|
|
1946
|
+
className: `mt-1.5 ${isNearLimit ? "text-indicator-warning" : "text-text-500"}`,
|
|
1947
|
+
children: [
|
|
1948
|
+
currentLength,
|
|
1949
|
+
"/",
|
|
1950
|
+
maxLength,
|
|
1951
|
+
" caracteres"
|
|
1952
|
+
]
|
|
1953
|
+
}
|
|
1954
|
+
),
|
|
1955
|
+
!errorMessage && helperMessage && !(showCharacterCount && maxLength) && /* @__PURE__ */ jsx14(Text_default, { size: "sm", weight: "normal", className: "mt-1.5 text-text-500", children: helperMessage })
|
|
1935
1956
|
] });
|
|
1936
1957
|
}
|
|
1937
1958
|
);
|
|
@@ -11194,6 +11215,7 @@ var useQuizStore = create10()(
|
|
|
11194
11215
|
userId: "",
|
|
11195
11216
|
variant: "default",
|
|
11196
11217
|
minuteCallback: null,
|
|
11218
|
+
dissertativeCharLimit: void 0,
|
|
11197
11219
|
questionsResult: null,
|
|
11198
11220
|
currentQuestionResult: null,
|
|
11199
11221
|
// Setters
|
|
@@ -11203,6 +11225,8 @@ var useQuizStore = create10()(
|
|
|
11203
11225
|
getUserId: () => get().userId,
|
|
11204
11226
|
setVariant: (variant) => set({ variant }),
|
|
11205
11227
|
setQuestionResult: (questionsResult) => set({ questionsResult }),
|
|
11228
|
+
setDissertativeCharLimit: (limit) => set({ dissertativeCharLimit: limit }),
|
|
11229
|
+
getDissertativeCharLimit: () => get().dissertativeCharLimit,
|
|
11206
11230
|
// Navigation
|
|
11207
11231
|
goToNextQuestion: () => {
|
|
11208
11232
|
const { currentQuestionIndex, getTotalQuestions } = get();
|
|
@@ -11292,7 +11316,7 @@ var useQuizStore = create10()(
|
|
|
11292
11316
|
});
|
|
11293
11317
|
},
|
|
11294
11318
|
selectDissertativeAnswer: (questionId, answer) => {
|
|
11295
|
-
const { quiz, userAnswers } = get();
|
|
11319
|
+
const { quiz, userAnswers, dissertativeCharLimit } = get();
|
|
11296
11320
|
if (!quiz) return;
|
|
11297
11321
|
const activityId = quiz.id;
|
|
11298
11322
|
const userId = get().getUserId();
|
|
@@ -11303,6 +11327,10 @@ var useQuizStore = create10()(
|
|
|
11303
11327
|
if (!question || question.questionType !== "DISSERTATIVA" /* DISSERTATIVA */) {
|
|
11304
11328
|
return;
|
|
11305
11329
|
}
|
|
11330
|
+
let validatedAnswer = answer;
|
|
11331
|
+
if (dissertativeCharLimit !== void 0 && answer.length > dissertativeCharLimit) {
|
|
11332
|
+
validatedAnswer = answer.substring(0, dissertativeCharLimit);
|
|
11333
|
+
}
|
|
11306
11334
|
const existingAnswerIndex = userAnswers.findIndex(
|
|
11307
11335
|
(answerItem) => answerItem.questionId === questionId
|
|
11308
11336
|
);
|
|
@@ -11310,7 +11338,7 @@ var useQuizStore = create10()(
|
|
|
11310
11338
|
questionId,
|
|
11311
11339
|
activityId,
|
|
11312
11340
|
userId,
|
|
11313
|
-
answer,
|
|
11341
|
+
answer: validatedAnswer,
|
|
11314
11342
|
optionId: null,
|
|
11315
11343
|
questionType: "DISSERTATIVA" /* DISSERTATIVA */,
|
|
11316
11344
|
answerStatus: "PENDENTE_AVALIACAO" /* PENDENTE_AVALIACAO */
|
|
@@ -11423,6 +11451,7 @@ var useQuizStore = create10()(
|
|
|
11423
11451
|
userId: "",
|
|
11424
11452
|
variant: "default",
|
|
11425
11453
|
minuteCallback: null,
|
|
11454
|
+
dissertativeCharLimit: void 0,
|
|
11426
11455
|
questionsResult: null,
|
|
11427
11456
|
currentQuestionResult: null
|
|
11428
11457
|
});
|
|
@@ -12037,7 +12066,8 @@ var QuizDissertative = ({ paddingBottom }) => {
|
|
|
12037
12066
|
getCurrentAnswer,
|
|
12038
12067
|
selectDissertativeAnswer,
|
|
12039
12068
|
getQuestionResultByQuestionId,
|
|
12040
|
-
variant
|
|
12069
|
+
variant,
|
|
12070
|
+
getDissertativeCharLimit
|
|
12041
12071
|
} = useQuizStore();
|
|
12042
12072
|
const currentQuestion = getCurrentQuestion();
|
|
12043
12073
|
const currentQuestionResult = getQuestionResultByQuestionId(
|
|
@@ -12045,6 +12075,7 @@ var QuizDissertative = ({ paddingBottom }) => {
|
|
|
12045
12075
|
);
|
|
12046
12076
|
const currentAnswer = getCurrentAnswer();
|
|
12047
12077
|
const textareaRef = useRef14(null);
|
|
12078
|
+
const charLimit = getDissertativeCharLimit();
|
|
12048
12079
|
const handleAnswerChange = (value) => {
|
|
12049
12080
|
if (currentQuestion) {
|
|
12050
12081
|
selectDissertativeAnswer(currentQuestion.id, value);
|
|
@@ -12077,7 +12108,9 @@ var QuizDissertative = ({ paddingBottom }) => {
|
|
|
12077
12108
|
value: localAnswer,
|
|
12078
12109
|
onChange: (e) => handleAnswerChange(e.target.value),
|
|
12079
12110
|
rows: 4,
|
|
12080
|
-
className: "min-h-[120px] max-h-[400px] resize-none overflow-y-auto"
|
|
12111
|
+
className: "min-h-[120px] max-h-[400px] resize-none overflow-y-auto",
|
|
12112
|
+
maxLength: charLimit,
|
|
12113
|
+
showCharacterCount: !!charLimit
|
|
12081
12114
|
}
|
|
12082
12115
|
) }) : /* @__PURE__ */ jsx54("div", { className: "space-y-4", children: /* @__PURE__ */ jsx54("p", { className: "text-text-600 text-md whitespace-pre-wrap", children: localAnswer || "Nenhuma resposta fornecida" }) }) }) }),
|
|
12083
12116
|
variant === "result" && currentQuestionResult?.answerStatus == "RESPOSTA_INCORRETA" /* RESPOSTA_INCORRETA */ && /* @__PURE__ */ jsxs39(Fragment11, { children: [
|