analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
197 lines (195 loc) • 6.04 kB
JavaScript
import {
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
Select_default
} from "./chunk-UU7Q5S52.mjs";
import {
DataBar,
GridLines,
LegendItem,
YAxis,
calculateYAxisTicks
} from "./chunk-Y4MZ2KAU.mjs";
import {
Text_default
} from "./chunk-IMCIR6TJ.mjs";
import {
cn
} from "./chunk-53ICLDGS.mjs";
// src/components/PerformanceQuestionsData/PerformanceQuestionsData.tsx
import { jsx, jsxs } from "react/jsx-runtime";
var PerformanceQuestionsVariant = /* @__PURE__ */ ((PerformanceQuestionsVariant2) => {
PerformanceQuestionsVariant2["QUESTIONS"] = "questions";
PerformanceQuestionsVariant2["CONTENT"] = "content";
return PerformanceQuestionsVariant2;
})(PerformanceQuestionsVariant || {});
var QUESTIONS_COLORS = {
total: "bg-info-600",
correct: "bg-success-200",
incorrect: "bg-warning-400",
blank: "bg-background-300"
};
var CONTENT_COLORS = {
total: "bg-info-600",
totalActivities: "bg-success-700",
totalRecommendedLessons: "bg-warning-300"
};
var VARIANT_TITLES = {
questions: "Dados de quest\xF5es",
content: "Dados de material produzido"
};
var buildQuestionsBarItems = (data) => [
{
key: "total",
label: "Total",
legendLabel: "Total de quest\xF5es respondidas",
value: data.total,
colorClass: QUESTIONS_COLORS.total
},
{
key: "correct",
label: "Corretas",
legendLabel: "Quest\xF5es corretas",
value: data.correct,
colorClass: QUESTIONS_COLORS.correct
},
{
key: "incorrect",
label: "Incorretas",
legendLabel: "Quest\xF5es incorretas",
value: data.incorrect,
colorClass: QUESTIONS_COLORS.incorrect
},
{
key: "blank",
label: "Em branco",
legendLabel: "Quest\xF5es em branco",
value: data.blank,
colorClass: QUESTIONS_COLORS.blank
}
];
var buildContentBarItems = (data) => [
{
key: "total",
label: "Total",
legendLabel: "Total",
value: data.total,
colorClass: CONTENT_COLORS.total
},
{
key: "totalActivities",
label: "Atividades",
legendLabel: "Atividades",
value: data.totalActivities,
colorClass: CONTENT_COLORS.totalActivities
},
{
key: "totalRecommendedLessons",
label: "Aulas recomendadas",
legendLabel: "Aulas recomendadas",
value: data.totalRecommendedLessons,
colorClass: CONTENT_COLORS.totalRecommendedLessons
}
];
var FilterSelect = ({ filter }) => /* @__PURE__ */ jsxs(
Select_default,
{
value: filter.value,
onValueChange: filter.onChange,
size: "small",
className: "w-auto",
children: [
/* @__PURE__ */ jsxs(
SelectTrigger,
{
variant: "outlined",
className: "whitespace-nowrap overflow-hidden",
children: [
filter.icon && /* @__PURE__ */ jsx("span", { className: "text-text-700 [&>svg]:w-4 [&>svg]:h-4 mr-2 flex-shrink-0", children: filter.icon }),
/* @__PURE__ */ jsx("span", { className: "truncate", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: filter.placeholder }) })
]
}
),
/* @__PURE__ */ jsx(SelectContent, { children: filter.options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
]
}
);
var PerformanceQuestionsData = ({
variant,
data,
subjectFilter,
activityTypeFilter,
maxValue,
chartHeight = 180,
className,
...props
}) => {
const title = VARIANT_TITLES[variant];
const barItems = variant === "questions" /* QUESTIONS */ ? buildQuestionsBarItems(data) : buildContentBarItems(data);
const chartMaxValue = maxValue ?? data.total;
const yAxisTicks = calculateYAxisTicks(chartMaxValue);
const adjustedMaxValue = yAxisTicks[0];
return /* @__PURE__ */ jsxs(
"div",
{
className: cn(
"flex flex-col p-5 gap-4 bg-background border border-border-50 rounded-xl",
className
),
...props,
children: [
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center justify-between gap-4", children: [
/* @__PURE__ */ jsx(
Text_default,
{
as: "h3",
size: "lg",
weight: "bold",
className: "text-text-950 tracking-[0.2px]",
children: title
}
),
(subjectFilter || activityTypeFilter) && /* @__PURE__ */ jsxs("div", { className: "flex flex-row gap-3", children: [
subjectFilter && /* @__PURE__ */ jsx(FilterSelect, { filter: subjectFilter }),
activityTypeFilter && /* @__PURE__ */ jsx(FilterSelect, { filter: activityTypeFilter })
] })
] }),
/* @__PURE__ */ jsx("div", { className: "flex flex-row flex-wrap gap-x-6 gap-y-2 mb-4", children: barItems.map((item) => /* @__PURE__ */ jsx(
LegendItem,
{
color: item.colorClass,
label: item.legendLabel
},
item.key
)) }),
/* @__PURE__ */ jsxs("div", { className: "flex flex-row", children: [
/* @__PURE__ */ jsx(YAxis, { ticks: yAxisTicks, chartHeight }),
/* @__PURE__ */ jsx("div", { className: "w-4" }),
/* @__PURE__ */ jsxs("div", { className: "flex-1 relative", children: [
/* @__PURE__ */ jsx(GridLines, { ticks: yAxisTicks, chartHeight }),
/* @__PURE__ */ jsx("div", { className: "flex flex-row flex-1 gap-4 relative z-10", children: barItems.map((item) => /* @__PURE__ */ jsx(
DataBar,
{
label: item.label,
value: item.value,
maxValue: adjustedMaxValue,
colorClass: item.colorClass,
chartHeight
},
item.key
)) })
] })
] })
]
}
);
};
var PerformanceQuestionsData_default = PerformanceQuestionsData;
export {
PerformanceQuestionsVariant,
PerformanceQuestionsData,
PerformanceQuestionsData_default
};
//# sourceMappingURL=chunk-ER2TQ5MG.mjs.map