UNPKG

analytica-frontend-lib

Version:

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

183 lines (164 loc) 5.96 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _chunk4E56FKY7js = require('./chunk-4E56FKY7.js'); var _chunkANT66KVKjs = require('./chunk-ANT66KVK.js'); var _chunkTN3AYOMVjs = require('./chunk-TN3AYOMV.js'); // src/components/PerformanceRanking/PerformanceRanking.tsx var _react = require('@phosphor-icons/react'); var _jsxruntime = require('react/jsx-runtime'); var POSITION_TEXT_CLASSES = { highlight: "text-text-950", attention: "text-text" }; var COUNT_BADGE_CLASSES = { highlight: "bg-success-background text-success-800", attention: "bg-error-background text-error-800" }; function TrendIcon({ trend, variant }) { if (trend === "up") { return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.TrendUpIcon, { size: 16, weight: "bold", "aria-hidden": "true" }); } if (trend === "down") { return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.TrendDownIcon, { size: 16, weight: "bold", "aria-hidden": "true" }); } const DefaultIcon = variant === "highlight" ? _react.TrendUpIcon : _react.TrendDownIcon; return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DefaultIcon, { size: 16, weight: "bold", "aria-hidden": "true" }); } function buildDisplayName(item) { const parts = [item.name]; if (item.shift) parts.push(`(${item.shift})`); if (item.grade) parts.push(`(${item.grade})`); return parts.join(" "); } function PerformanceItemCard({ item, variant, countLabel }) { const backgroundClass = _chunk4E56FKY7js.getPositionBackgroundClass.call(void 0, variant, item.position); const displayName = buildDisplayName(item); const countText = countLabel ? `${item.count} ${countLabel}` : String(item.count); return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkTN3AYOMVjs.cn.call(void 0, "flex flex-row items-center w-full p-4 gap-2 rounded-xl", backgroundClass ), children: [ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { size: "xs", weight: "bold", "aria-label": `Position ${item.position}`, className: _chunkTN3AYOMVjs.cn.call(void 0, "w-5 h-5 rounded-full flex items-center justify-center flex-shrink-0", POSITION_TEXT_CLASSES[variant], _chunk4E56FKY7js.BADGE_BACKGROUND_CLASSES[variant] ), children: item.position } ), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { size: "sm", weight: "bold", className: "flex-1 min-w-0 text-text-950 tracking-[0.2px] truncate", children: displayName } ), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { size: "xs", "aria-label": `Count ${item.count}`, className: _chunkTN3AYOMVjs.cn.call(void 0, "flex-shrink-0 h-[22px] px-2 flex items-center rounded", COUNT_BADGE_CLASSES[variant] ), children: countText } ), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkANT66KVKjs.Text_default, { size: "xs", weight: "bold", "aria-label": `Performance ${item.percentage}%`, className: _chunkTN3AYOMVjs.cn.call(void 0, "flex flex-row items-center flex-shrink-0 h-[22px] px-2 gap-1 rounded text-text", _chunk4E56FKY7js.PERCENTAGE_BADGE_CLASSES[variant] ), children: [ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TrendIcon, { trend: item.trend, variant }), item.percentage, "%" ] } ) ] } ); } function createRenderPerformanceItem(countLabel) { return function renderPerformanceItem(item, variant, index) { if (!item) { return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center justify-center w-full p-4 rounded-xl bg-background-50 border border-dashed border-border-100", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { size: "xs", className: "text-text-400", children: "Sem dados" }) }, `${variant}-empty-${index}` ); } return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PerformanceItemCard, { item, variant, countLabel }, `${variant}-${index}-${item.position}` ); }; } var PerformanceRanking = ({ data, highlightTitle = "Em destaque", attentionTitle = "Precisando de aten\xE7\xE3o", countLabel, className, ...props }) => { const renderItem = createRenderPerformanceItem(countLabel); return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk4E56FKY7js.RankingLayout, { className, ...props, children: [ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk4E56FKY7js.BaseRankingCard, { title: highlightTitle, variant: "highlight", items: data.highlighted, renderItem, headerIcon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.MedalIcon, { size: 14, className: "text-text-950" }) } ), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk4E56FKY7js.BaseRankingCard, { title: attentionTitle, variant: "attention", items: data.needsAttention, renderItem, headerIcon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.SealWarningIcon, { size: 14, className: "text-text" }) } ) ] }); }; var PerformanceRanking_default = PerformanceRanking; exports.PerformanceRanking = PerformanceRanking; exports.PerformanceRanking_default = PerformanceRanking_default; //# sourceMappingURL=chunk-CQA4NUH5.js.map