UNPKG

analytica-frontend-lib

Version:

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

145 lines (143 loc) 4.14 kB
import { ReportLayout } from "./chunk-JPAENAZB.mjs"; import { Text_default } from "./chunk-IMCIR6TJ.mjs"; import { cn } from "./chunk-53ICLDGS.mjs"; // src/components/TimeReport/TimeReport.tsx import { TrendUpIcon } from "@phosphor-icons/react/dist/csr/TrendUp"; import { TrendDownIcon } from "@phosphor-icons/react/dist/csr/TrendDown"; import dayjs from "dayjs"; import duration from "dayjs/plugin/duration"; import { jsx, jsxs } from "react/jsx-runtime"; dayjs.extend(duration); var formatHoursToTime = (hours) => { const d = dayjs.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: TrendUpIcon }, down: { colorClass: "text-error-500", Icon: TrendDownIcon } }; var TimeCard = ({ data, className, ...props }) => { const { label, value, icon, trendValue, trendDirection, footer, subtitle } = data; return /* @__PURE__ */ jsxs( "div", { className: cn( "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__ */ jsxs("div", { className: "flex flex-row items-center gap-2", children: [ /* @__PURE__ */ jsx("span", { className: "text-text-600 [&>svg]:w-4 [&>svg]:h-4", children: icon }), /* @__PURE__ */ jsx( Text_default, { weight: "bold", className: "text-text-600 uppercase text-[8px] leading-[100%]", children: label } ) ] }), /* @__PURE__ */ jsx( Text_default, { size: "2xl", weight: "bold", className: "text-primary-800 leading-[100%] tracking-[0.2px]", children: value } ), subtitle && /* @__PURE__ */ jsx( Text_default, { size: "sm", className: "text-text-600 leading-[100%]", "data-testid": `subtitle-${data.id}`, children: subtitle } ), trendValue && trendDirection && /* @__PURE__ */ jsxs( "div", { className: cn( "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__ */ jsx(TrendIcon, { size: 16, weight: "bold" }); })(), /* @__PURE__ */ jsx( Text_default, { size: "xs", weight: "bold", color: "inherit", className: "leading-[100%] uppercase", children: trendValue } ) ] } ), footer !== void 0 && footer !== null && footer !== false && /* @__PURE__ */ jsx(Text_default, { as: "div", size: "xs", className: "text-text-500 leading-[130%]", children: footer }) ] } ); }; var TimeReport = ({ tabs, defaultTab, activeTab, onTabChange, className, ...props }) => /* @__PURE__ */ jsx( ReportLayout, { tabs, defaultTab, activeTab, onTabChange, renderCard: (card) => /* @__PURE__ */ jsx(TimeCard, { data: card }, card.id), gridTestId: "time-report-cards", className, ...props } ); var TimeReport_default = TimeReport; export { formatHoursToTime, getTrendDirection, formatVariation, TimeCard, TimeReport, TimeReport_default }; //# sourceMappingURL=chunk-DP2FWRSQ.mjs.map