UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

124 lines (110 loc) 4.23 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _chunkFCCPBAAQjs = require('./chunk-FCCPBAAQ.js'); var _chunkANT66KVKjs = require('./chunk-ANT66KVK.js'); var _chunkTN3AYOMVjs = require('./chunk-TN3AYOMV.js'); // src/components/QuestionsData/QuestionsData.tsx var _jsxruntime = require('react/jsx-runtime'); var BAR_COLORS = { total: "bg-info-600", corretas: "bg-success-200", incorretas: "bg-warning-400", emBranco: "bg-background-300" }; var QuestionsData = ({ title = "Dados de quest\xF5es", data, showEmBranco = false, maxValue, chartHeight = 180, className, ...props }) => { const chartMaxValue = _nullishCoalesce(maxValue, () => ( data.total)); const yAxisTicks = _chunkFCCPBAAQjs.calculateYAxisTicks.call(void 0, chartMaxValue); const adjustedMaxValue = yAxisTicks[0]; const blankSuffix = showEmBranco && data.emBranco !== void 0 ? `, ${data.emBranco} em branco` : ""; const chartDescription = `Gr\xE1fico de barras mostrando ${data.total} quest\xF5es respondidas, ${data.corretas} corretas, ${data.incorretas} incorretas${blankSuffix}`; const barItems = [ { key: "total", label: "Total", legendLabel: "Total de quest\xF5es respondidas", value: data.total, colorClass: BAR_COLORS.total }, { key: "corretas", label: "Corretas", legendLabel: "Quest\xF5es corretas", value: data.corretas, colorClass: BAR_COLORS.corretas }, { key: "incorretas", label: "Incorretas", legendLabel: "Quest\xF5es incorretas", value: data.incorretas, colorClass: BAR_COLORS.incorretas } ]; if (showEmBranco && data.emBranco !== void 0) { barItems.push({ key: "emBranco", label: "Em branco", legendLabel: "Quest\xF5es em branco", value: data.emBranco, colorClass: BAR_COLORS.emBranco }); } 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.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { as: "h3", size: "lg", weight: "bold", className: "text-text-950 tracking-[0.2px]", children: title } ), /* @__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: BAR_COLORS[item.key], label: item.legendLabel }, item.key )) }), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-row", "aria-label": chartDescription, 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 QuestionsData_default = QuestionsData; exports.QuestionsData = QuestionsData; exports.QuestionsData_default = QuestionsData_default; //# sourceMappingURL=chunk-WC53FQQN.js.map