UNPKG

analytica-frontend-lib

Version:

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

145 lines (131 loc) 5.07 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _chunkHJTAGNGSjs = require('./chunk-HJTAGNGS.js'); var _chunkANT66KVKjs = require('./chunk-ANT66KVK.js'); var _chunkTN3AYOMVjs = require('./chunk-TN3AYOMV.js'); // src/components/TimeReport/TimeReport.tsx var _TrendUp = require('@phosphor-icons/react/dist/csr/TrendUp'); var _TrendDown = require('@phosphor-icons/react/dist/csr/TrendDown'); var _dayjs = require('dayjs'); var _dayjs2 = _interopRequireDefault(_dayjs); var _duration = require('dayjs/plugin/duration'); var _duration2 = _interopRequireDefault(_duration); var _jsxruntime = require('react/jsx-runtime'); _dayjs2.default.extend(_duration2.default); var formatHoursToTime = (hours) => { const d = _dayjs2.default.duration(hours, "hours"); const h = Math.floor(d.asHours()); const min = d.minutes(); return `${h}h ${min}min`; }; var getTrendDirection = (variationPercent) => { if (variationPercent === null) return void 0; return variationPercent >= 0 ? "up" : "down"; }; var formatVariation = (variationPercent) => { if (variationPercent === null) return void 0; const sign = variationPercent >= 0 ? "+" : ""; return `${sign}${variationPercent}%`; }; var TREND_CONFIG = { up: { colorClass: "text-success-500", Icon: _TrendUp.TrendUpIcon }, down: { colorClass: "text-error-500", Icon: _TrendDown.TrendDownIcon } }; var TimeCard = ({ data, className, ...props }) => { const { label, value, icon, trendValue, trendDirection, footer, subtitle } = data; return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkTN3AYOMVjs.cn.call(void 0, "flex flex-col gap-3 p-5 bg-background border border-border-50 rounded-xl", className ), "data-testid": `time-card-${data.id}`, ...props, children: [ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-row items-center gap-2", children: [ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-text-600 [&>svg]:w-4 [&>svg]:h-4", children: icon }), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { weight: "bold", className: "text-text-600 uppercase text-[8px] leading-[100%]", children: label } ) ] }), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { size: "2xl", weight: "bold", className: "text-primary-800 leading-[100%] tracking-[0.2px]", children: value } ), subtitle && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { size: "sm", className: "text-text-600 leading-[100%]", "data-testid": `subtitle-${data.id}`, children: subtitle } ), trendValue && trendDirection && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkTN3AYOMVjs.cn.call(void 0, "flex flex-row items-center gap-1", TREND_CONFIG[trendDirection].colorClass ), "data-testid": `trend-${data.id}`, children: [ (() => { const TrendIcon = TREND_CONFIG[trendDirection].Icon; return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TrendIcon, { size: 16, weight: "bold" }); })(), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { size: "xs", weight: "bold", color: "inherit", className: "leading-[100%] uppercase", children: trendValue } ) ] } ), footer !== void 0 && footer !== null && footer !== false && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkANT66KVKjs.Text_default, { as: "div", size: "xs", className: "text-text-500 leading-[130%]", children: footer }) ] } ); }; var TimeReport = ({ tabs, defaultTab, activeTab, onTabChange, className, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHJTAGNGSjs.ReportLayout, { tabs, defaultTab, activeTab, onTabChange, renderCard: (card) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TimeCard, { data: card }, card.id), gridTestId: "time-report-cards", className, ...props } ); var TimeReport_default = TimeReport; exports.formatHoursToTime = formatHoursToTime; exports.getTrendDirection = getTrendDirection; exports.formatVariation = formatVariation; exports.TimeCard = TimeCard; exports.TimeReport = TimeReport; exports.TimeReport_default = TimeReport_default; //# sourceMappingURL=chunk-FVU7P5YQ.js.map