@financinha/ui 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +37 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -5
- package/dist/index.d.ts +8 -5
- package/dist/index.js +37 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2480,20 +2480,39 @@ var import_class_variance_authority7 = require("class-variance-authority");
|
|
|
2480
2480
|
var import_radix_ui12 = require("radix-ui");
|
|
2481
2481
|
var import_cn25 = require("cn");
|
|
2482
2482
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2483
|
-
var
|
|
2483
|
+
var OUTLINE_DETAILS = [
|
|
2484
|
+
// O título do resumo em destaque: semibold, na cor do texto.
|
|
2485
|
+
"[&>[data-slot=item-content]>[data-slot=item-title]]:font-semibold [&>[data-slot=item-content]>[data-slot=item-title]]:text-foreground",
|
|
2486
|
+
// As linhas de detalhe (um ItemGroup dentro da caixa) ocupam a linha toda, abaixo de uma divisória de ponta a ponta,
|
|
2487
|
+
// com 8 px entre a divisória e o texto e entre o texto e a borda de baixo.
|
|
2488
|
+
"[&>[data-slot=item-group]]:-mx-2 [&>[data-slot=item-group]]:mt-1 [&>[data-slot=item-group]]:-mb-1 [&>[data-slot=item-group]]:basis-[calc(100%+1rem)] [&>[data-slot=item-group]]:border-t [&>[data-slot=item-group]]:border-border [&>[data-slot=item-group]]:px-2 [&>[data-slot=item-group]]:pt-1",
|
|
2489
|
+
// Cada linha de detalhe: 4 px em cima e embaixo, nome e valor em cinza, valor sem negrito.
|
|
2490
|
+
"[&>[data-slot=item-group]>[data-slot=item]]:py-1 [&>[data-slot=item-group]_[data-slot=item-title]]:text-muted-foreground [&>[data-slot=item-group]_[data-slot=item-actions]]:font-normal [&>[data-slot=item-group]_[data-slot=item-actions]]:text-muted-foreground"
|
|
2491
|
+
].join(" ");
|
|
2492
|
+
var itemVariants = (0, import_class_variance_authority7.cva)("group/item flex flex-wrap items-center gap-y-1 text-sm", {
|
|
2484
2493
|
variants: {
|
|
2485
2494
|
variant: {
|
|
2486
2495
|
// Solta, sem fundo: as linhas de uma lista.
|
|
2487
2496
|
default: "py-2",
|
|
2488
2497
|
// Bloco cinza com borda: o resumo dentro de um card ("Saldo total", "Ganho total").
|
|
2489
|
-
subtle: "rounded-lg border border-border bg-muted px-4 py-3"
|
|
2498
|
+
subtle: "rounded-lg border border-border bg-muted px-4 py-3",
|
|
2499
|
+
// Caixa branca com borda e 8 px de espaço: o resumo dentro de um card, com o título em destaque e, se quiser,
|
|
2500
|
+
// as linhas de detalhe dentro dela (um ItemGroup). Não é um Card: card dentro de card continua proibido.
|
|
2501
|
+
outline: (0, import_cn25.cn)("rounded-lg border border-border bg-card p-2", OUTLINE_DETAILS)
|
|
2502
|
+
},
|
|
2503
|
+
size: {
|
|
2504
|
+
// 16 px no título e no valor.
|
|
2505
|
+
default: "gap-x-3",
|
|
2506
|
+
// 14 px no título e no valor (ItemTitle e ItemActions leem o data-size), e 8 px entre as partes: resumos densos.
|
|
2507
|
+
sm: "gap-x-2"
|
|
2490
2508
|
}
|
|
2491
2509
|
},
|
|
2492
|
-
defaultVariants: { variant: "default" }
|
|
2510
|
+
defaultVariants: { variant: "default", size: "default" }
|
|
2493
2511
|
});
|
|
2494
2512
|
function Item({
|
|
2495
2513
|
className,
|
|
2496
2514
|
variant,
|
|
2515
|
+
size,
|
|
2497
2516
|
asChild = false,
|
|
2498
2517
|
...props
|
|
2499
2518
|
}) {
|
|
@@ -2503,7 +2522,8 @@ function Item({
|
|
|
2503
2522
|
{
|
|
2504
2523
|
"data-slot": "item",
|
|
2505
2524
|
"data-variant": variant ?? "default",
|
|
2506
|
-
|
|
2525
|
+
"data-size": size ?? "default",
|
|
2526
|
+
className: (0, import_cn25.cn)(itemVariants({ variant, size }), className),
|
|
2507
2527
|
...props
|
|
2508
2528
|
}
|
|
2509
2529
|
);
|
|
@@ -2524,7 +2544,8 @@ function ItemGroup({
|
|
|
2524
2544
|
);
|
|
2525
2545
|
}
|
|
2526
2546
|
var MEDIA_TONE = {
|
|
2527
|
-
|
|
2547
|
+
// Azul (apoio), como no MetricCard: o cinza fazia o ícone parecer desabilitado.
|
|
2548
|
+
neutral: "bg-support-50 text-support-500 dark:bg-support-800/40 dark:text-support-300",
|
|
2528
2549
|
success: "bg-success-50 text-success-500 dark:bg-success-800/40 dark:text-success-300",
|
|
2529
2550
|
danger: "bg-danger-50 text-danger-500 dark:bg-danger-800/40 dark:text-danger-300"
|
|
2530
2551
|
};
|
|
@@ -2549,14 +2570,14 @@ function ItemMedia({
|
|
|
2549
2570
|
);
|
|
2550
2571
|
}
|
|
2551
2572
|
function ItemContent({ className, ...props }) {
|
|
2552
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { "data-slot": "item-content", className: (0, import_cn25.cn)("flex min-w-
|
|
2573
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { "data-slot": "item-content", className: (0, import_cn25.cn)("flex min-w-16 flex-1 flex-col gap-1", className), ...props });
|
|
2553
2574
|
}
|
|
2554
2575
|
function ItemTitle({ className, ...props }) {
|
|
2555
2576
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2556
2577
|
"div",
|
|
2557
2578
|
{
|
|
2558
2579
|
"data-slot": "item-title",
|
|
2559
|
-
className: (0, import_cn25.cn)(textStyle("text1"), "flex items-center gap-2 leading-tight text-foreground group-data-[variant=subtle]/item:text-neutral-600", className),
|
|
2580
|
+
className: (0, import_cn25.cn)(textStyle("text1"), "flex items-center gap-2 leading-tight text-foreground group-data-[variant=subtle]/item:text-neutral-600 group-data-[size=sm]/item:text-sm group-data-[size=sm]/item:leading-5", className),
|
|
2560
2581
|
...props
|
|
2561
2582
|
}
|
|
2562
2583
|
);
|
|
@@ -2569,7 +2590,7 @@ function ItemActions({ className, ...props }) {
|
|
|
2569
2590
|
"div",
|
|
2570
2591
|
{
|
|
2571
2592
|
"data-slot": "item-actions",
|
|
2572
|
-
className: (0, import_cn25.cn)("ml-auto flex shrink-0 items-center gap-2 text-base font-semibold text-foreground tabular-nums", className),
|
|
2593
|
+
className: (0, import_cn25.cn)("ml-auto flex shrink-0 items-center gap-2 text-base font-semibold text-foreground tabular-nums group-data-[size=sm]/item:text-sm", className),
|
|
2573
2594
|
...props
|
|
2574
2595
|
}
|
|
2575
2596
|
);
|
|
@@ -2992,7 +3013,7 @@ var formatadores = /* @__PURE__ */ new Map();
|
|
|
2992
3013
|
function formatador(moeda) {
|
|
2993
3014
|
let f = formatadores.get(moeda);
|
|
2994
3015
|
if (!f) {
|
|
2995
|
-
f = new Intl.NumberFormat("pt-BR", { style: "currency", currency: moeda });
|
|
3016
|
+
f = new Intl.NumberFormat("pt-BR", { style: "currency", currency: moeda, currencyDisplay: "narrowSymbol" });
|
|
2996
3017
|
formatadores.set(moeda, f);
|
|
2997
3018
|
}
|
|
2998
3019
|
return f;
|
|
@@ -3003,14 +3024,17 @@ var COR = {
|
|
|
3003
3024
|
expense: "text-danger-500"
|
|
3004
3025
|
};
|
|
3005
3026
|
function Amount({ value, currency = "BRL", tone = "neutral", showSign = true, hidden = false, className, ...props }) {
|
|
3006
|
-
const
|
|
3027
|
+
const porSinal = value > 0 ? "income" : value < 0 ? "expense" : "neutral";
|
|
3028
|
+
const saldoPositivo = tone === "balance" && value > 0;
|
|
3029
|
+
const tipo = tone === "auto" ? porSinal : tone === "balance" ? saldoPositivo ? "neutral" : porSinal : tone;
|
|
3007
3030
|
const negativo = tipo === "expense" || tipo === "neutral" && value < 0;
|
|
3008
|
-
const
|
|
3009
|
-
const
|
|
3031
|
+
const positivo = tipo === "income" || saldoPositivo;
|
|
3032
|
+
const sinal = positivo ? "+" : negativo ? "\u2212" : "";
|
|
3033
|
+
const mostraSinal = sinal !== "" && (tipo === "neutral" && !saldoPositivo || showSign);
|
|
3010
3034
|
const f = formatador(currency);
|
|
3011
3035
|
const texto = f.format(Math.abs(value));
|
|
3012
3036
|
const simbolo = f.formatToParts(0).find((p) => p.type === "currency")?.value ?? currency;
|
|
3013
|
-
const falado = hidden ? "Valor oculto" : `${negativo ? "menos " :
|
|
3037
|
+
const falado = hidden ? "Valor oculto" : `${negativo ? "menos " : positivo && mostraSinal ? "mais " : ""}${texto}`;
|
|
3014
3038
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
3015
3039
|
"span",
|
|
3016
3040
|
{
|