analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
197 lines (176 loc) • 7.02 kB
JavaScript
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
var _chunkHGWU3GUNjs = require('./chunk-HGWU3GUN.js');
var _chunkFCCPBAAQjs = require('./chunk-FCCPBAAQ.js');
var _chunkANT66KVKjs = require('./chunk-ANT66KVK.js');
var _chunkTN3AYOMVjs = require('./chunk-TN3AYOMV.js');
// src/components/PerformanceQuestionsData/PerformanceQuestionsData.tsx
var _jsxruntime = require('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__ */ _jsxruntime.jsxs.call(void 0,
_chunkHGWU3GUNjs.Select_default,
{
value: filter.value,
onValueChange: filter.onChange,
size: "small",
className: "w-auto",
children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
_chunkHGWU3GUNjs.SelectTrigger,
{
variant: "outlined",
className: "whitespace-nowrap overflow-hidden",
children: [
filter.icon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-text-700 [&>svg]:w-4 [&>svg]:h-4 mr-2 flex-shrink-0", children: filter.icon }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "truncate", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHGWU3GUNjs.SelectValue, { placeholder: filter.placeholder }) })
]
}
),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHGWU3GUNjs.SelectContent, { children: filter.options.map((option) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHGWU3GUNjs.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 = _nullishCoalesce(maxValue, () => ( data.total));
const yAxisTicks = _chunkFCCPBAAQjs.calculateYAxisTicks.call(void 0, chartMaxValue);
const adjustedMaxValue = yAxisTicks[0];
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
"div",
{
className: _chunkTN3AYOMVjs.cn.call(void 0,
"flex flex-col p-5 gap-4 bg-background border border-border-50 rounded-xl",
className
),
...props,
children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-row items-center justify-between gap-4", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkANT66KVKjs.Text_default,
{
as: "h3",
size: "lg",
weight: "bold",
className: "text-text-950 tracking-[0.2px]",
children: title
}
),
(subjectFilter || activityTypeFilter) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-row gap-3", children: [
subjectFilter && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FilterSelect, { filter: subjectFilter }),
activityTypeFilter && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FilterSelect, { filter: activityTypeFilter })
] })
] }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-row flex-wrap gap-x-6 gap-y-2 mb-4", children: barItems.map((item) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkFCCPBAAQjs.LegendItem,
{
color: item.colorClass,
label: item.legendLabel
},
item.key
)) }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-row", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkFCCPBAAQjs.YAxis, { ticks: yAxisTicks, chartHeight }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-4" }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex-1 relative", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkFCCPBAAQjs.GridLines, { ticks: yAxisTicks, chartHeight }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-row flex-1 gap-4 relative z-10", children: barItems.map((item) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkFCCPBAAQjs.DataBar,
{
label: item.label,
value: item.value,
maxValue: adjustedMaxValue,
colorClass: item.colorClass,
chartHeight
},
item.key
)) })
] })
] })
]
}
);
};
var PerformanceQuestionsData_default = PerformanceQuestionsData;
exports.PerformanceQuestionsVariant = PerformanceQuestionsVariant; exports.PerformanceQuestionsData = PerformanceQuestionsData; exports.PerformanceQuestionsData_default = PerformanceQuestionsData_default;
//# sourceMappingURL=chunk-CRGEI3IQ.js.map